fez-lisp 1.4.19 → 1.5.0
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 +5 -5
- package/lib/baked/macros.js +1 -1
- package/lib/baked/std.js +1 -1
- package/package.json +1 -1
- package/src/compiler.js +1 -1
- package/src/interpreter.js +1 -1
- package/src/keywords.js +1 -1
- package/src/utils.js +14 -15
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
|
-
(
|
18
|
-
(
|
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
|
@@ -108,13 +108,13 @@ console.log(compile(parse("(+ 1 2)")))
|
|
108
108
|
console.log(compile(parse("(math:power 2 4)")))
|
109
109
|
// (()=>{;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
110
|
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,
|
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),
|
111
|
+
/* (()=>{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];
|
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),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
113
|
```
|
114
114
|
|
115
115
|
```lisp
|
116
116
|
; Build-in all keywords
|
117
117
|
(/ ...) (+ ...) (* ...) (- ...) (= ...) (< ...) (> ...) (>= ...) (<= ...) (& ...) (~ ...) (| ...) (^ ...) (<< ...) (>> ...) (>>> ...)
|
118
118
|
(mod ...) (let ...) (if ...) (not ...) (and ...) (or ...) (atom? ...) (lambda? ...)
|
119
|
-
(length ...) (do ...) (array ...) (
|
119
|
+
(length ...) (do ...) (array ...) (alter! ...) (get ...) (lambda ...) (apply ...) (throw ...)
|
120
120
|
```
|