fez-lisp 1.4.20 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,8 +14,8 @@
14
14
  (let x 42)
15
15
  ; But array items are not
16
16
  (let arr (array 1 2 3))
17
- (set! arr 0 10)
18
- (set! arr (length arr) 100)
17
+ (alter! arr 0 10)
18
+ (alter! arr (length arr) 100)
19
19
  ; arr is now will make it [10 2 3 100]
20
20
  ; No strings - instead they are array of charcodes
21
21
  "Hello World!" ; This is syntactic suggar turning it into the one below
@@ -77,19 +77,6 @@ Installation:
77
77
  npm i fez-lisp
78
78
  ```
79
79
 
80
- ```js
81
- import { parse, debug } from 'fez-lisp'
82
- debug(parse(`(log "Hello World!" "str")`)) // Hello World!
83
- ```
84
-
85
- ```js
86
- import { parse, debug } from 'fez-lisp'
87
- debug(parse(`(+ 1 (array 2))`)).error.message // TypeError: Second arguments of (+) is not a (number) at: (+ 1 (array 2) scope: (apply)
88
- ```
89
-
90
- ````js
91
-
92
-
93
80
  ```lisp
94
81
  (let fizz-buzz (lambda n
95
82
  (cond
@@ -99,7 +86,7 @@ debug(parse(`(+ 1 (array 2))`)).error.message // TypeError: Second arguments of
99
86
  (*) (from:number->string n))))
100
87
 
101
88
  (|> (math:range 1 100) (array:map fizz-buzz) (array:commas) (log "str"))
102
- ````
89
+ ```
103
90
 
104
91
  ```js
105
92
  import { parse, compile } from 'fez-lisp'
@@ -108,13 +95,13 @@ console.log(compile(parse("(+ 1 2)")))
108
95
  console.log(compile(parse("(math:power 2 4)")))
109
96
  // (()=>{;return(()=>{var math_power;return (math_power=((base,exp)=>{return (+(exp<0)?(+(base===0)?[]:(1/(base*math_power(base,((exp*-1)-1))))):(+(exp===0)?1:(+(exp===1)?base:(1?(base*math_power(base,(exp-1))):0))));}),math_power(2,4));})()})()
110
97
  console.log(compile(parse("(|> [1 2 3 4] (array:map math:square) (math:summation))")))
111
- /* (()=>{var __tco=fn=>(...args)=>{let result=fn(...args);while(typeof result==='function')result=result();return result},length=(arr)=>arr.length,set_effect=function(array,index,value){if(arguments.length===1){array.pop()}else{array[index] = value};return array},get=(arr,i)=>arr[i];
112
- ;return(()=>{var math_summation,math_square,array_map,array_fold;return (math_summation=((xs)=>{return array_fold(xs,((a,b)=>{return (a+b);}),0);}),math_square=((x)=>{return (x*x);}),array_map=((xs,callback)=>{var recursive_array_map,recursive_9271675;return ((recursive_array_map=(__tco(recursive_9271675=(i,out)=>{return (+(length(xs)>i)?()=>recursive_9271675((i+1),set_effect(out,length(out),callback(get(xs, i)))):out);}, recursive_9271675))),recursive_array_map(0,[]));}),array_fold=((xs,callback,initial)=>{var recursive_array_fold,recursive_927729;return ((recursive_array_fold=(__tco(recursive_927729=(i,out)=>{return (+(length(xs)>i)?()=>recursive_927729((i+1),callback(out,get(xs, i))):out);}, recursive_927729))),recursive_array_fold(0,initial));}),math_summation(array_map([1,2,3,4],math_square)));})()})() * /
98
+ /* (()=>{var __tco=fn=>(...args)=>{let result=fn(...args);while(typeof result==='function')result=result();return result},length=(arr)=>arr.length,alter_effect=function(array,index,value){if(arguments.length===1){array.pop()}else{array[index] = value};return array},get=(arr,i)=>arr[i];
99
+ ;return(()=>{var math_summation,math_square,array_map,array_fold;return (math_summation=((xs)=>{return array_fold(xs,((a,b)=>{return (a+b);}),0);}),math_square=((x)=>{return (x*x);}),array_map=((xs,callback)=>{var recursive_array_map,recursive_9271675;return ((recursive_array_map=(__tco(recursive_9271675=(i,out)=>{return (+(length(xs)>i)?()=>recursive_9271675((i+1),alter_effect(out,length(out),callback(get(xs, i)))):out);}, recursive_9271675))),recursive_array_map(0,[]));}),array_fold=((xs,callback,initial)=>{var recursive_array_fold,recursive_927729;return ((recursive_array_fold=(__tco(recursive_927729=(i,out)=>{return (+(length(xs)>i)?()=>recursive_927729((i+1),callback(out,get(xs, i))):out);}, recursive_927729))),recursive_array_fold(0,initial));}),math_summation(array_map([1,2,3,4],math_square)));})()})() * /
113
100
  ```
114
101
 
115
102
  ```lisp
116
103
  ; Build-in all keywords
117
104
  (/ ...) (+ ...) (* ...) (- ...) (= ...) (< ...) (> ...) (>= ...) (<= ...) (& ...) (~ ...) (| ...) (^ ...) (<< ...) (>> ...) (>>> ...)
118
105
  (mod ...) (let ...) (if ...) (not ...) (and ...) (or ...) (atom? ...) (lambda? ...)
119
- (length ...) (do ...) (array ...) (set! ...) (get ...) (lambda ...) (apply ...) (throw ...)
106
+ (length ...) (do ...) (array ...) (alter! ...) (get ...) (lambda ...) (apply ...) (throw ...)
120
107
  ```
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { evaluate } from './src/evaluator.js'
2
2
  import { compile } from './src/compiler.js'
3
- import { debug, parse } from './src/utils.js'
3
+ import { parse } from './src/utils.js'
4
4
  import { LISP, AST } from './src/parser.js'
5
- export { parse, evaluate, compile, debug, LISP, AST }
5
+ export { parse, evaluate, compile, LISP, AST }
@@ -168,7 +168,7 @@ export const SLICE_RAW = [
168
168
  [2, 1]
169
169
  ],
170
170
  [
171
- [0, 'set!'],
171
+ [0, 'alter!'],
172
172
  [1, 'out'],
173
173
  [
174
174
  [0, 'length'],