fez-lisp 1.6.38 → 1.6.40
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 +74 -5
- package/lib/baked/std.js +1 -1
- package/package.json +1 -1
- package/src/check.js +60 -9
package/README.md
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
# Fez Programming Language
|
2
2
|
|
3
|
-
<p align="center">
|
4
|
-
<img width="128" src="./favicon.svg"/>
|
5
|
-
</p>
|
6
|
-
|
7
3
|
```lisp
|
8
4
|
(let fezz-buzz (lambda n
|
9
5
|
(cond
|
@@ -50,6 +46,80 @@
|
|
50
46
|
(mod ...) (let ...) (if ...) (not ...) (and ...) (or ...) (atom? ...) (lambda? ...)
|
51
47
|
(length ...) (do ...) (array ...) (set! ...) (pop! ...) (get ...) (lambda ...) (apply ...)
|
52
48
|
|
49
|
+
; Arithmetic Operators
|
50
|
+
; +: Addition.
|
51
|
+
(+ a b) ; → returns the sum of a and b.
|
52
|
+
; -: Subtraction.
|
53
|
+
(- a b) ; → returns a minus b.
|
54
|
+
; *: Multiplication.
|
55
|
+
(* a b) ; → returns the product of a and b.
|
56
|
+
; /: Division.
|
57
|
+
(/ a b) ; → returns a divided by b.
|
58
|
+
; mod: Modulo (remainder).
|
59
|
+
(mod a b) ; → returns the remainder of a divided by b.
|
60
|
+
; Comparison Operators
|
61
|
+
; =: Equality.
|
62
|
+
(= a b) ; → returns 1 if a equals b, else 0.
|
63
|
+
; <: Less than.
|
64
|
+
(< a b) ; → returns 1 if a is less than b, else 0.
|
65
|
+
; >: Greater than.
|
66
|
+
(> a b) ; → returns 1 if a is greater than b, else 0.
|
67
|
+
; <=: Less than or equal.
|
68
|
+
(<= a b) ; → returns 1 if a is less than or equal to b, else 0.
|
69
|
+
; >=: Greater than or equal.
|
70
|
+
(>= a b) ; → returns 1 if a is greater than or equal to b, else 0.
|
71
|
+
; Bitwise Operators
|
72
|
+
; &: Bitwise AND.
|
73
|
+
(& a b)
|
74
|
+
; |: Bitwise OR.
|
75
|
+
(| a b)
|
76
|
+
; ^: Bitwise XOR.
|
77
|
+
(^ a b)
|
78
|
+
; ~: Bitwise NOT.
|
79
|
+
(~ a)
|
80
|
+
; <<: Bitwise left shift.
|
81
|
+
(<< a b)
|
82
|
+
; >>: Bitwise right shift.
|
83
|
+
(>> a b)
|
84
|
+
; Logical Operators
|
85
|
+
; and: Logical AND.
|
86
|
+
(and a b) ; → returns a if a is 0, else b.
|
87
|
+
; or: Logical OR.
|
88
|
+
(or a b) ; → returns 1 if a is 1, else b.
|
89
|
+
; not: Logical NOT.
|
90
|
+
(not a) ; → returns 1 if a is 0, else 0.
|
91
|
+
; Control Flow
|
92
|
+
; if: Conditional.
|
93
|
+
(if cond then else) → evaluates then if cond is true, else else.
|
94
|
+
; do: Sequence.
|
95
|
+
(do expr1 expr2 ...) → evaluates each expression in order, returns the last.
|
96
|
+
; loop: While loop.
|
97
|
+
(loop cond body) → repeatedly evaluates body while cond is true.
|
98
|
+
; Functions
|
99
|
+
; lambda: Function definition.
|
100
|
+
(lambda x y (do ...)) ; → returns a function of x and y.
|
101
|
+
; apply: Function application.
|
102
|
+
(apply f a b ...) → applies function f to arguments.
|
103
|
+
; Variables
|
104
|
+
; let: Variable definition.
|
105
|
+
(let x 10) → defines x as 10.
|
106
|
+
; set!: Array element assignment.
|
107
|
+
(set! arr idx val) → sets arr[idx] to val.
|
108
|
+
; pop!: Array pop.
|
109
|
+
(pop! arr) → removes the last element from arr.
|
110
|
+
; Arrays
|
111
|
+
; array: Array creation.
|
112
|
+
(array 1 2 3) → creates [1, 2, 3].
|
113
|
+
; get: Array element access.
|
114
|
+
(get arr idx) ; → returns arr[idx].
|
115
|
+
; length: Array length.
|
116
|
+
(length arr) ; → returns the number of elements in arr.
|
117
|
+
; Type Predicates
|
118
|
+
; atom?: Checks if value is a number.
|
119
|
+
(atom? x) ; → returns 1 if x is a number, else 0.
|
120
|
+
; lambda?: Checks if value is a function.
|
121
|
+
(lambda? x) ; → returns 1 if x is a function, else 0.
|
122
|
+
|
53
123
|
; Important Note:
|
54
124
|
; In this programming language, parentheses are used to group expressions and define the structure of code.
|
55
125
|
; It is essential to keep the number of opening and closing parentheses balanced.
|
@@ -433,5 +503,4 @@
|
|
433
503
|
; - Variable redeclaration: Do not redeclare (let) a variable that already exists in the same scope. Redeclaring variables can cause bugs or unexpected behavior. Always use unique variable names within a given scope, or update the variable using the appropriate set! or var:set! helper.
|
434
504
|
; - (get) vs (array:get): (get) and (array:get) are the same under the hood. (get xs) with one argument is equivalent to (get xs 0), returning the first element. However, you should only use (get) for variables declared with (variable) syntactic sugar (numbers only). For arrays, always use (array:get). For booleans, use (boole:true?) or related helpers. This avoids ambiguity and makes your code clearer and less error-prone.
|
435
505
|
|
436
|
-
|
437
506
|
```
|