History

add /= and update the docs for comparison operators

Sigrid Solveig Haflínudóttir committed 1 year ago

Commit 1b155961 parent 049f0336 files · +28 −26Browse files

Unified · Split

6 files
  1. docs_extra.lsp +2 −15
  2. flisp.boot +8 −6
  3. flisp.boot.builtin +0 −0
  4. system.lsp +14 −1
  5. test/color.lsp +2 −2
  6. test/unittest.lsp +3 −3
docs_extra.lsp+2−15
@@ -9,21 +9,8 @@ · 8 unmodified lines
9 (error "docs: " sym ": funvars set but isn't a function")))9 (error "docs: " sym ": funvars set but isn't a function")))
10 `(symbol-set-doc ',sym ',doc ',funvars)))10 `(symbol-set-doc ',sym ',doc ',funvars)))
11 11
12(doc-for (< a . rest)12(doc-for (= a . rest)
13 "Return #t if the arguments are in strictly increasing order (previous13 "Return #t if the arguments are equal.")
14one is less than the next one).")
15
16(doc-for (<= a . rest)
17 "Return #t if the arguments are in non-decreasing order (previous
18one is less than or equal to the next one).")
19
20(doc-for (> a . rest)
21 "Return #t if the arguments are in strictly decreasing order (previous
22one is greater than the next one).")
23
24(doc-for (>= a . rest)
25 "Return #t if the arguments are in non-increasing order (previous
26one is greater than or equal to the next one).")
27 14
28(doc-for (vm-stats)15(doc-for (vm-stats)
29 "Print various VM-related information, such as the number of GC calls16 "Print various VM-related information, such as the number of GC calls
flisp.boot+8−6
@@ -16,10 +16,11 @@ · 15 unmodified lines
16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #fn("8000z0700}2:" #(aref)) 0 0)16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #fn("8000z0700}2:" #(aref)) 0 0)
17 *properties* #table(*funvars* #table(>= ((a . rest)) void? ((x)) length= ((lst n)) help ((term)) lz-unpack ((data17 *properties* #table(*funvars* #table(>= ((a . rest)) void? ((x)) length= ((lst n)) help ((term)) lz-unpack ((data
18 :to destination)18 :to destination)
19 (data :size decompressed-bytes)) <= ((a . rest)) car ((lst)) < ((a . rest)) void (rest) *prompt* (nil) lz-pack ((data19 (data :size decompressed-bytes)) = ((a . rest)) <= ((a . rest)) car ((lst)) /= ((a . rest)) void (rest) *prompt* (nil) nan? ((x)) lz-pack ((data
20 (level 0))) cons? ((value)) vm-stats (nil) * ((number…)) cdr ((lst)) + ((number…)) > ((a . rest))) *doc* #table(+ "Return sum of the numbers or 0 with no arguments." >= "Return #t if the arguments are in non-increasing order (previous\none is greater than or equal to the next one)." void? "Return #t if x is #<void> and #f otherwise." length= "Bounded length test.\nUse this instead of (= (length lst) n), since it avoids unnecessary\nwork and always terminates." help "Display documentation for the specified term, if available." lz-unpack "Return decompressed data previously compressed using lz-pack.\nEither destination for the decompressed data or the expected size of\nthe decompressed data must be specified. In the latter case a new\narray is allocated." <= "Return #t if the arguments are in non-decreasing order (previous\none is less than or equal to the next one)." *builtins* "VM instructions as closures." car "Returns the first element of a list or nil if not available." < "Return #t if the arguments are in strictly increasing order (previous\none is less than the next one)." void "Return the constant #<void> while ignoring any arguments.\n#<void> is mainly used when a function has side effects but does not\nproduce any meaningful value to return, so even though #t or nil could\nbe returned instead, in case of #<void> alone, REPL will not print\nit." arg-counts "VM instructions mapped to their expected arguments count." *prompt* "Function called by REPL to signal the user input is required.\nDefault function prints \"#;> \"." lz-pack "Return data compressed using Lempel-Ziv.\nThe data must be an array, returned value will have the same type.\nThe optional level is between 0 and 10. With level 0 a simple LZSS\nusing hashing will be performed. Levels between 1 and 9 offer a\ntrade-off between time/space and ratio. Level 10 is optimal but very\nslow." Instructions "VM instructions mapped to their encoded byte representation." cons? "Returns #t if the value is a cons cell." vm-stats "Print various VM-related information, such as the number of GC calls\nso far, heap and stack size, etc." * "Return product of the numbers or 1 with no arguments." > "Return #t if the arguments are in strictly decreasing order (previous\none is greater than the next one)." cdr "Returns the tail of a list or nil if not available." *properties* "All properties of symbols recorded with putprop are recorded in this table."))20 (level 0))) cons? ((value)) vm-stats (nil) * ((number…)) cdr ((lst)) > ((a . rest)) + ((number…))) *doc* #table(+ "Return sum of the numbers or 0 with no arguments." >= "Return #t if the arguments are in non-increasing order (previous\none is greater than or equal to the next one)." void? "Return #t if x is #<void> and #f otherwise." length= "Bounded length test.\nUse this instead of (= (length lst) n), since it avoids unnecessary\nwork and always terminates." help "Display documentation for the specified term, if available." lz-unpack "Return decompressed data previously compressed using lz-pack.\nEither destination for the decompressed data or the expected size of\nthe decompressed data must be specified. In the latter case a new\narray is allocated." = "Return #t if the arguments are equal." <= "Return #t if the arguments are in non-decreasing order (previous\none is less than or equal to the next one)." *builtins* "VM instructions as closures." car "Returns the first element of a list or nil if not available." /= "Return #t if not all arguments are equal. Shorthand for (not (= …))." void "Return the constant #<void> while ignoring any arguments.\n#<void> is mainly used when a function has side effects but does not\nproduce any meaningful value to return, so even though #t or nil could\nbe returned instead, in case of #<void> alone, REPL will not print\nit." arg-counts "VM instructions mapped to their expected arguments count." nan? "Return #t if the argument is equal to NaN, regardless of the sign." *prompt* "Function called by REPL to signal the user input is required.\nDefault function prints \"#;> \"." Instructions "VM instructions mapped to their encoded byte representation." lz-pack "Return data compressed using Lempel-Ziv.\nThe data must be an array, returned value will have the same type.\nThe optional level is between 0 and 10. With level 0 a simple LZSS\nusing hashing will be performed. Levels between 1 and 9 offer a\ntrade-off between time/space and ratio. Level 10 is optimal but very\nslow." vm-stats "Print various VM-related information, such as the number of GC calls\nso far, heap and stack size, etc." cons? "Returns #t if the value is a cons cell." * "Return product of the numbers or 1 with no arguments." > "Return #t if the arguments are in strictly decreasing order (previous\none is greater than the next one)." cdr "Returns the tail of a list or nil if not available." *properties* "All properties of symbols recorded with putprop are recorded in this table."))
21 *runestring-type* (array rune) *string-type* (array byte)21 *runestring-type* (array rune) *string-type* (array byte)
22 *syntax-environment* #table(when #fn(";000z1200211POe4:" #(if begin)) unwind-protect #fn("A000n220502050218722q1e3e2e1232402286e12587e12686e2e3e3e387e1e3e3:" #(#fn(gensym)22 *syntax-environment* #table(throw #fn("9000n220212223e201e4e2:" #(raise list quote
23 thrown-value)) unwind-protect #fn("A000n220502050218722q1e3e2e1232402286e12587e12686e2e3e3e387e1e3e3:" #(#fn(gensym)
23 let λ prog1 trycatch begin raise)) help #fn(";000n17002152853W072855147350424250>170026q535247350@B0722728051524735047960:" #(getprop24 let λ prog1 trycatch begin raise)) help #fn(";000n17002152853W072855147350424250>170026q535247350@B0722728051524735047960:" #(getprop
24 *doc* princ newline #fn(for-each) #fn("7000n17050471A0P61:" #(newline print)) *funvars* "no help for "25 *doc* princ newline #fn(for-each) #fn("7000n17050471A0P61:" #(newline print)) *funvars* "no help for "
25 #fn(string) void)) with-output-to #fn("<000z12021e1220e2e1e12315163:" #(#fn(nconc) with-bindings26 #fn(string) void)) with-output-to #fn("<000z12021e1220e2e1e12315163:" #(#fn(nconc) with-bindings
@@ -28,7 +29,8 @@ · 2 unmodified lines
28 λ #fn(copy-list) caar let* cadar)) with-input-from #fn("<000z12021e1220e2e1e12315163:" #(#fn(nconc)29 λ #fn(copy-list) caar let* cadar)) with-input-from #fn("<000z12021e1220e2e1e12315163:" #(#fn(nconc)
29 with-bindings *input-stream* #fn(copy-list))) unless #fn("<000z1200O211Pe4:" #(if begin)) letrec #fn(">000z1202021e12273052e122240522515154e1222605262:" #(#fn(nconc)30 with-bindings *input-stream* #fn(copy-list))) unless #fn("<000z1200O211Pe4:" #(if begin)) letrec #fn(">000z1202021e12273052e122240522515154e1222605262:" #(#fn(nconc)
30 λ #fn(map) car #fn("8000n12021e12205162:" #(#fn(nconc) set! #fn(copy-list)))31 λ #fn(map) car #fn("8000n12021e12205162:" #(#fn(nconc) set! #fn(copy-list)))
31 #fn(copy-list) #fn("5000n17060:" #(void)))) time #fn(">000n12050218522e1e2e123024252622e185e32728e5e3e3:" #(#fn(gensym)32 #fn(copy-list) #fn("5000n17060:" #(void)))) /= #fn("=000z1202122e10e12315153e2:" #(not #fn(nconc)
33 = #fn(copy-list))) time #fn(">000n12050218522e1e2e123024252622e185e32728e5e3e3:" #(#fn(gensym)
32 let time-now prog1 princ "Elapsed time: " - " seconds" *linefeed*)) cond #fn(";000z0\x8d\x8a520852185>1_51485<061:" #(#0=#fn("7000z0\x8d:" #() void)34 let time-now prog1 princ "Elapsed time: " - " seconds" *linefeed*)) cond #fn(";000z0\x8d\x8a520852185>1_51485<061:" #(#0=#fn("7000z0\x8d:" #() void)
33 #fn(">000n10H340O:0<85<20Q;I80485<DQ3C085=J6085<:2185=P:85=J@02285<A<0=51e3:85T23C\x98074758551513c07675855151278685<e2e12886217975855151PA<0=51e4e3:2:50278685<e2e1288675855186e2A<0=51e4e3:2885<2185=PA<0=51e4:" #(else35 #fn(">000n10H340O:0<85<20Q;I80485<DQ3C085=J6085<:2185=P:85=J@02285<A<0=51e3:85T23C\x98074758551513c07675855151278685<e2e12886217975855151PA<0=51e4e3:2:50278685<e2e1288675855186e2A<0=51e4e3:2885<2185=PA<0=51e4:" #(else
34 begin or => 1arg-lambda? caddr caadr let if cddr #fn(gensym)) cond-clauses->if))) do #fn("J000z220501<2172052217305221240522587268927882829e12:1=51522829e12:82512887e18;52e153e4e3e2e12887e18:52e3:" #(#fn(gensym)36 begin or => 1arg-lambda? caddr caadr let if cddr #fn(gensym)) cond-clauses->if))) do #fn("J000z220501<2172052217305221240522587268927882829e12:1=51522829e12:82512887e18;52e153e4e3e2e12887e18:52e3:" #(#fn(gensym)
@@ -44,8 +46,8 @@ · 9 unmodified lines
44 symbol-set-doc set-syntax! quote #fn(nconc) λ #fn(copy-list))) receive #fn("?000z22021q1e32221e10e123825153e3:" #(call-with-values46 symbol-set-doc set-syntax! quote #fn(nconc) λ #fn(copy-list))) receive #fn("?000z22021q1e32221e10e123825153e3:" #(call-with-values
45 λ #fn(nconc) #fn(copy-list))) dotimes #fn("A000z10<0T20E2187Ke32223e186e1e12415153e4:" #(for -47 λ #fn(nconc) #fn(copy-list))) dotimes #fn("A000z10<0T20E2187Ke32223e186e1e12415153e4:" #(for -
46 #fn(nconc) λ #fn(copy-list))) > #fn("<000z12021e12273151510e163:" #(#fn(nconc) < #fn(copy-list)48 #fn(nconc) λ #fn(copy-list))) > #fn("<000z12021e12273151510e163:" #(#fn(nconc) < #fn(copy-list)
47 reverse!)) throw #fn("9000n220212223e201e4e2:" #(raise49 reverse!)) quasiquote #fn("7000n1700E62:" #(bq-process)) when #fn(";000z1200211POe4:" #(if
48 list quote thrown-value)) quasiquote #fn("7000n1700E62:" #(bq-process)))50 begin)))
49 1+ #fn("6000n10KM:" #() 1+) 1-51 1+ #fn("6000n10KM:" #() 1+) 1-
50 #fn("6000n10K~:" #() 1-) 1arg-lambda? #fn("7000n10B;3E04700<51;3:04710TK62:" #(is-lambda?52 #fn("6000n10K~:" #() 1-) 1arg-lambda? #fn("7000n10B;3E04700<51;3:04710TK62:" #(is-lambda?
51 length=) 1arg-lambda?)53 length=) 1arg-lambda?)
flisp.boot.builtin+0−0

Binary file not shown.

system.lsp+14−1
@@ -173,9 +173,14 @@ it." · 172 unmodified lines
173 ((eqv? (caar lst) item) (car lst))173 ((eqv? (caar lst) item) (car lst))
174 (#t (assv item (cdr lst)))))174 (#t (assv item (cdr lst)))))
175 175
176(define (nan? x) (or (equal? x +nan.0) (equal? x -nan.0)))176(define (nan? x)
177 "Return #t if the argument is equal to NaN, regardless of the sign."
178 (or (equal? x +nan.0)
179 (equal? x -nan.0)))
177 180
178(define (> a . rest)181(define (> a . rest)
182 "Return #t if the arguments are in strictly decreasing order (previous
183one is greater than the next one)."
179 (define (f a rest)184 (define (f a rest)
180 (or (null? rest)185 (or (null? rest)
181 (and (< (car rest) a)186 (and (< (car rest) a)
@@ -185,6 +190,8 @@ it." · 3 unmodified lines
185 `(< ,@(reverse! rest) ,a))190 `(< ,@(reverse! rest) ,a))
186 191
187(define (<= a . rest)192(define (<= a . rest)
193 "Return #t if the arguments are in non-decreasing order (previous
194one is less than or equal to the next one)."
188 (define (f a rest)195 (define (f a rest)
189 (unless (null? rest)196 (unless (null? rest)
190 (or (< (car rest) a)197 (or (< (car rest) a)
@@ -193,6 +200,8 @@ it." · 2 unmodified lines
193 (not (f a rest)))200 (not (f a rest)))
194 201
195(define (>= a . rest)202(define (>= a . rest)
203 "Return #t if the arguments are in non-increasing order (previous
204one is greater than or equal to the next one)."
196 (define (f a rest)205 (define (f a rest)
197 (unless (null? rest)206 (unless (null? rest)
198 (or (< a (car rest))207 (or (< a (car rest))
@@ -200,6 +209,10 @@ it." · 1 unmodified line
200 (f (car rest) (cdr rest)))))209 (f (car rest) (cdr rest)))))
201 (not (f a rest)))210 (not (f a rest)))
202 211
212(define-macro (/= a . rest)
213 "Return #t if not all arguments are equal. Shorthand for (not (= …))."
214 `(not (= ,a ,@rest)))
215
203(define (negative? x) (< x 0))216(define (negative? x) (< x 0))
204(define (zero? x) (= x 0))217(define (zero? x) (= x 0))
205(define (positive? x) (> x 0))218(define (positive? x) (> x 0))
test/color.lsp+2−2
@@ -84,6 +84,6 @@ · 83 unmodified lines
84 (let ((result ()))84 (let ((result ()))
85 (dotimes (x 25)85 (dotimes (x 25)
86 (dotimes (y 25)86 (dotimes (y 25)
87 (if (and (not (= x y)) (can-attack x y))87 (when (and (/= x y) (can-attack x y))
88 (set! result (cons (cons x y) result)) ())))88 (set! result (cons (cons x y) result)))))
89 result))89 result))
test/unittest.lsp+3−3
@@ -120,9 +120,9 @@ · 119 unmodified lines
120; NaNs120; NaNs
121(assert (equal? +nan.0 +nan.0))121(assert (equal? +nan.0 +nan.0))
122(assert (equal? -nan.0 -nan.0))122(assert (equal? -nan.0 -nan.0))
123(assert (not (= +nan.0 +nan.0)))123(assert (/= +nan.0 +nan.0))
124(assert (not (= +nan.0 -nan.0)))124(assert (/= +nan.0 -nan.0))
125(assert (not (= -nan.0 -nan.0)))125(assert (/= -nan.0 -nan.0))
126(assert (equal? (< +nan.0 3) (> 3 +nan.0)))126(assert (equal? (< +nan.0 3) (> 3 +nan.0)))
127(assert (equal? (< +nan.0 (double 3)) (> (double 3) +nan.0)))127(assert (equal? (< +nan.0 (double 3)) (> (double 3) +nan.0)))
128(assert (equal? (< +nan.0 3) (> (double 3) +nan.0)))128(assert (equal? (< +nan.0 3) (> (double 3) +nan.0)))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t