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
99 (error "docs: " sym ": funvars set but isn't a function")))
1010 `(symbol-set-doc ',sym ',doc ',funvars)))
1111
12−(doc-for (< a . rest)
13− "Return #t if the arguments are in strictly increasing order (previous
14−one is less than the next one).")
15−
16−(doc-for (<= a . rest)
17− "Return #t if the arguments are in non-decreasing order (previous
18−one 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
22−one is greater than the next one).")
23−
24−(doc-for (>= a . rest)
25− "Return #t if the arguments are in non-increasing order (previous
26−one is greater than or equal to the next one).")
12+(doc-for (= a . rest)
13+ "Return #t if the arguments are equal.")
2714
2815 (doc-for (vm-stats)
2916 "Print various VM-related information, such as the number of GC calls
flisp.boot+8−6
@@ -16,10 +16,11 @@ · 15 unmodified lines
1616 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 #fn("8000z0700}2:" #(aref)) 0 0)
1717 *properties* #table(*funvars* #table(>= ((a . rest)) void? ((x)) length= ((lst n)) help ((term)) lz-unpack ((data
1818 :to destination)
19− (data :size decompressed-bytes)) <= ((a . rest)) car ((lst)) < ((a . rest)) void (rest) *prompt* (nil) 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."))
19+ (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)) > ((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."))
2121 *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)
2324 let λ prog1 trycatch begin raise)) help #fn(";000n17002152853W072855147350424250>170026q535247350@B0722728051524735047960:" #(getprop
2425 *doc* princ newline #fn(for-each) #fn("7000n17050471A0P61:" #(newline print)) *funvars* "no help for "
2526 #fn(string) void)) with-output-to #fn("<000z12021e1220e2e1e12315163:" #(#fn(nconc) with-bindings
@@ -28,7 +29,8 @@ · 2 unmodified lines
2829 λ #fn(copy-list) caar let* cadar)) with-input-from #fn("<000z12021e1220e2e1e12315163:" #(#fn(nconc)
2930 with-bindings *input-stream* #fn(copy-list))) unless #fn("<000z1200O211Pe4:" #(if begin)) letrec #fn(">000z1202021e12273052e122240522515154e1222605262:" #(#fn(nconc)
3031 λ #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)
3234 let time-now prog1 princ "Elapsed time: " - " seconds" *linefeed*)) cond #fn(";000z0\x8d\x8a520852185>1_51485<061:" #(#0=#fn("7000z0\x8d:" #() void)
3335 #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
3436 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
4446 symbol-set-doc set-syntax! quote #fn(nconc) λ #fn(copy-list))) receive #fn("?000z22021q1e32221e10e123825153e3:" #(call-with-values
4547 λ #fn(nconc) #fn(copy-list))) dotimes #fn("A000z10<0T20E2187Ke32223e186e1e12415153e4:" #(for -
4648 #fn(nconc) λ #fn(copy-list))) > #fn("<000z12021e12273151510e163:" #(#fn(nconc) < #fn(copy-list)
47− reverse!)) throw #fn("9000n220212223e201e4e2:" #(raise
48− list quote thrown-value)) quasiquote #fn("7000n1700E62:" #(bq-process)))
49+ reverse!)) quasiquote #fn("7000n1700E62:" #(bq-process)) when #fn(";000z1200211POe4:" #(if
50+ begin)))
4951 1+ #fn("6000n10KM:" #() 1+) 1-
5052 #fn("6000n10K~:" #() 1-) 1arg-lambda? #fn("7000n10B;3E04700<51;3:04710TK62:" #(is-lambda?
5153 length=) 1arg-lambda?)
flisp.boot.builtin+0−0

Binary file not shown.

system.lsp+14−1
@@ -173,9 +173,14 @@ it." · 172 unmodified lines
173173 ((eqv? (caar lst) item) (car lst))
174174 (#t (assv item (cdr lst)))))
175175
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)))
177180
178181 (define (> a . rest)
182+ "Return #t if the arguments are in strictly decreasing order (previous
183+one is greater than the next one)."
179184 (define (f a rest)
180185 (or (null? rest)
181186 (and (< (car rest) a)
@@ -185,6 +190,8 @@ it." · 3 unmodified lines
185190 `(< ,@(reverse! rest) ,a))
186191
187192 (define (<= a . rest)
193+ "Return #t if the arguments are in non-decreasing order (previous
194+one is less than or equal to the next one)."
188195 (define (f a rest)
189196 (unless (null? rest)
190197 (or (< (car rest) a)
@@ -193,6 +200,8 @@ it." · 2 unmodified lines
193200 (not (f a rest)))
194201
195202 (define (>= a . rest)
203+ "Return #t if the arguments are in non-increasing order (previous
204+one is greater than or equal to the next one)."
196205 (define (f a rest)
197206 (unless (null? rest)
198207 (or (< a (car rest))
@@ -200,6 +209,10 @@ it." · 1 unmodified line
200209 (f (car rest) (cdr rest)))))
201210 (not (f a rest)))
202211
212+(define-macro (/= a . rest)
213+ "Return #t if not all arguments are equal. Shorthand for (not (= …))."
214+ `(not (= ,a ,@rest)))
215+
203216 (define (negative? x) (< x 0))
204217 (define (zero? x) (= x 0))
205218 (define (positive? x) (> x 0))
test/color.lsp+2−2
@@ -84,6 +84,6 @@ · 83 unmodified lines
8484 (let ((result ()))
8585 (dotimes (x 25)
8686 (dotimes (y 25)
87− (if (and (not (= x y)) (can-attack x y))
88− (set! result (cons (cons x y) result)) ())))
87+ (when (and (/= x y) (can-attack x y))
88+ (set! result (cons (cons x y) result)))))
8989 result))
test/unittest.lsp+3−3
@@ -120,9 +120,9 @@ · 119 unmodified lines
120120 ; NaNs
121121 (assert (equal? +nan.0 +nan.0))
122122 (assert (equal? -nan.0 -nan.0))
123−(assert (not (= +nan.0 +nan.0)))
124−(assert (not (= +nan.0 -nan.0)))
125−(assert (not (= -nan.0 -nan.0)))
123+(assert (/= +nan.0 +nan.0))
124+(assert (/= +nan.0 -nan.0))
125+(assert (/= -nan.0 -nan.0))
126126 (assert (equal? (< +nan.0 3) (> 3 +nan.0)))
127127 (assert (equal? (< +nan.0 (double 3)) (> (double 3) +nan.0)))
128128 (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