History

split docs.sl into multiple files to group things better

Sigrid Solveig Haflínudóttir committed 3 months ago

Commit 8f4ac6f1 parent a75d65b19 files · +1741 −1731Browse files

Unified · Split

19 files
  1. boot/sl.boot +77 −74
  2. src/docs.sl +17 −1639
  3. src/docs_array.sl +63 −0
  4. src/docs_compress.sl +21 −0
  5. src/docs_debug.sl +7 −0
  6. src/docs_io.sl +434 −0
  7. src/docs_list.sl +68 −0
  8. src/docs_misc.sl +90 −0
  9. src/docs_number.sl +323 −0
  10. src/docs_random.sl +60 −0
  11. src/docs_seq.sl +0 −0
  12. src/docs_string.sl +117 −0
  13. src/docs_struct.sl +69 −0
  14. src/docs_sys.sl +84 −0
  15. src/docs_table.sl +81 −0
  16. src/docs_time.sl +55 −0
  17. src/docs_type.sl +78 −0
  18. src/docs_vm.sl +93 −0
  19. src/system.sl +4 −18
boot/sl.boot+77−74
@@ -16,7 +16,7 @@ NIL NIL) · 15 unmodified lines
16less-than? (:key identity))) fixnum? ((v)) exit (((msg NIL) (code 0))) __finish ((status)) caaar ((lst)) io-peek ((io16less-than? (:key identity))) fixnum? ((v)) exit (((msg NIL) (code 0))) __finish ((status)) caaar ((lst)) io-peek ((io
17type (endian +endianness+))17type (endian +endianness+))
18(io type (n NIL) (endian +endianness+))) s32 (((n 0))) u8 (((n 0))) any ((pred lst)) nthcdr ((lst18(io type (n NIL) (endian +endianness+))) s32 (((n 0))) u8 (((n 0))) any ((pred lst)) nthcdr ((lst
19n)) os-getenv ((name)) s8 (((n 0))) tag-of ((v)) io-close ((io)) io-line! ((io19n)) s8 (((n 0))) os-getenv ((name)) tag-of ((v)) io-close ((io)) io-line! ((io
20new-line-number)) num? ((v)) unquote-splicing ((expr)) assert ((expr)) vec->list ((vc)) 1+ ((n)) throw ((tag20new-line-number)) num? ((v)) unquote-splicing ((expr)) assert ((expr)) vec->list ((vc)) 1+ ((n)) throw ((tag
21value)) positive? ((n)) atan ((x) (y x)) remprop ((symbol key)) io-copy-until ((io-dest21value)) positive? ((n)) atan ((x) (y x)) remprop ((symbol key)) io-copy-until ((io-dest
22io-src r)) cdddar ((lst)) set-cdr! ((cell22io-src r)) cdddar ((lst)) set-cdr! ((cell
@@ -26,26 +26,25 @@ body₀ . rest) · 3 unmodified lines
26limit fn)) begin (body) const? ((term)) str-trim ((s (lead-pred rune-whitespace?) (trail-pred26limit fn)) begin (body) const? ((term)) str-trim ((s (lead-pred rune-whitespace?) (trail-pred
27lead-pred))) io-pos! ((io27lead-pred))) io-pos! ((io
28new-position)) return (((value (void)))) tan ((r)) table (rest) __rcscript (NIL) doc-group ((group-name28new-position)) return (((value (void)))) tan ((r)) table (rest) __rcscript (NIL) doc-group ((group-name
29doc)) cdaaar ((lst)) bounds-error ((seq index . msg)) even? ((n)) zero? ((n)) proper-list? ((v)) random ((max29doc)) cdaaar ((lst)) bounds-error ((seq index . msg)) even? ((n)) proper-list? ((v)) zero? ((n)) io-filename! ((io
30(state NIL))) io-filename! ((io new-name)) reverse! ((lst)) eval ((x)) cdaadr ((lst)) u32 (((n30new-name)) random ((max (state NIL))) reverse! ((lst)) eval ((x)) cdaadr ((lst)) cons ((first
310))) cons ((first second)) filter ((pred lst)) do ((vars test-spec . commands)) make-random-state (((state31second)) u32 (((n 0))) filter ((pred lst)) do ((vars test-spec . commands)) assq ((key lst)) io-buffer-mode! ((io)) let ((binds . body)
32NIL))) assq ((key lst)) let ((binds . body) (id binds . body)) io-buffer-mode! ((io)) del! ((table32(id binds . body)) make-random-state (((state NIL))) del! ((table key)) when ((cond . body)) vec? ((v)) cddaar ((lst)) num->str ((n
33key)) when ((cond . body)) vec? ((v)) cddaar ((lst)) num->str ((n (:base 10))) min ((v . rest)) io? ((term)) help (((topic33(:base 10))) min ((v . rest)) help (((topic NIL) (:print-header help-print-header) . rest)) io? ((term)) unquote-nsplicing ((expr)) mod ((a
34NIL)34n)) if ((cond then . else)) str-pad ((s n (:align :left) (:fill #\space))) p32 (((n 0))) case ((expr . clauses)) io-read-lines ((io)) io-line ((io)) zip-with ((fn . lst)) trycatch ((try
35(:print-header help-print-header) . rest)) unquote-nsplicing ((expr)) mod ((a n)) if ((cond
36then . else)) str-pad ((s n (:align :left) (:fill #\space))) p32 (((n 0))) case ((expr . clauses)) io-read-lines ((io)) io-line ((io)) zip-with ((fn . lst)) trycatch ((try
37catch)) macrocall? ((e)) iterate ((fn zero n)) builtin ((sym)) table-values ((ta)) macroexpand ((e)) caadr ((lst)) type-of ((v)) top-level-value ((sym)) defstruct ((name35catch)) macrocall? ((e)) iterate ((fn zero n)) builtin ((sym)) table-values ((ta)) macroexpand ((e)) caadr ((lst)) type-of ((v)) top-level-value ((sym)) defstruct ((name
38docs… options… (slot-1 DEFAULT) slot-2 slot-3)36docs… options… (slot-1 DEFAULT) slot-2 slot-3)
39(name (:type vec) (:named T) (:constructor T) (:conc-name T) (:predicate T) . slots)) caadar ((lst)) foldl1 ((fn37(name (:type vec) (:named T) (:constructor T) (:conc-name T) (:predicate T) . slots)) caadar ((lst)) foldl1 ((fn
40seq)) buffer (NIL (v (:start NIL) (:end NIL))) random-state? ((state)) assoc-list (kvs) builtin? ((v)) with-input (((var38seq)) buffer (NIL (v (:start NIL) (:end NIL))) random-state? ((state)) assoc-list (kvs) builtin? ((v)) with-input (((var
41expr) . body)) str-map ((fn s)) macroexpand-1 ((e)) remove-duplicates ((lst)) with-exception-bindings (body) str (terms) negative? ((n)) void (rest) io-read-line ((io)) assert-fail ((expr . what)) and (rest) 1- ((n)) io-buffer-mode ((io)) equal? ((a39expr) . body)) str-map ((fn s)) macroexpand-1 ((e)) remove-duplicates ((lst)) with-exception-bindings (body) str (terms) negative? ((n)) void (rest) io-read-line ((io)) assert-fail ((expr . what)) and (rest) 1- ((n)) io-buffer-mode ((io)) equal? ((a
42b)) unquote ((expr)) cddar ((lst)) or (rest) = ((n . rest)) fn? ((v)) caaadr ((lst)) make-system-image ((filename)) subseq ((seq40b)) unquote ((expr)) cddar ((lst)) or (rest) = ((n . rest)) fn? ((v)) caaadr ((lst)) make-system-image ((filename)) subseq ((seq
43start (end NIL))) set! ((id expr . rest)) vm-stats (((io *io-out*))) ptr (((n 0))) caddar ((lst)) print-stack-trace ((st)) cosh ((x)) values (v) < ((v . rest)) copy-tree ((lst)) f32 (((n41start (end NIL))) set! ((id expr . rest)) vm-stats (((io *io-out*))) caddar ((lst)) ptr (((n
420))) print-stack-trace ((st)) cosh ((x)) values (v) < ((v . rest)) copy-tree ((lst)) f32 (((n
440.0))) sin ((r)) io-copy ((io-dest io-src (n NIL))) > ((v . rest)) str-rune ((s n)) foldl ((fn430.0))) sin ((r)) io-copy ((io-dest io-src (n NIL))) > ((v . rest)) str-rune ((s n)) foldl ((fn
45zero . seqs)) with-output-to ((io . body)) abs ((n)) str? ((v)) cons? ((v)) str-split ((str44zero . seqs)) with-output-to ((io . body)) abs ((n)) str? ((v)) cons? ((v)) io-read ((io
46(sep " \n\t\v\f") (:trim NIL))) io-read ((io type (endian +endianness+))45type (endian +endianness+))
47(io type (n NIL) (endian +endianness+))) truncate ((x)) aset! ((sequence46(io type (n NIL) (endian +endianness+))) str-split ((str (sep " \n\t\v\f") (:trim NIL))) truncate ((x)) aset! ((sequence
48subscripts… new-value)) - ((n . rest)) makunbound ((sym)) io-truncate ((io nbytes)) quasiquote ((expr)) io-column! ((io47subscripts… new-value)) - ((n . rest)) io-truncate ((io nbytes)) makunbound ((sym)) quasiquote ((expr)) io-column! ((io
49new-column-number)) copy-list ((lst (n NIL))) logand (ints) time-now (NIL) sinh ((r)) top-level-exception-handler ((e)) identity ((v)) untrace ((sym)) count ((pred48new-column-number)) copy-list ((lst (n NIL))) logand (ints) time-now (NIL) sinh ((r)) top-level-exception-handler ((e)) identity ((v)) untrace ((sym)) count ((pred
50lst)) io-pos ((io)) map-int ((fn count)) table->assoc-list ((ta)) length< ((seq n)) unless ((cond . body)) str->time ((str)) get-syntax ((sym)) ptr? ((v)) expt ((x49lst)) io-pos ((io)) map-int ((fn count)) table->assoc-list ((ta)) length< ((seq n)) unless ((cond . body)) str->time ((str)) get-syntax ((sym)) ptr? ((v)) expt ((x
51p)) io-read-all ((io)) gc (NIL) io-write ((io v (endian +endianness+))) table-invert ((ta)) lz-unpack ((data50p)) io-read-all ((io)) gc (NIL) io-write ((io v (endian +endianness+))) table-invert ((ta)) lz-unpack ((data
@@ -56,8 +55,8 @@ key)) vec (rest) while ((cond . body)) rune (((n 65533))) cadar ((lst)) typ · 4 unmodified lines
56got-value . msg)) file ((path (mode 420) (:read NIL) (:write NIL) (:create NIL) (:truncate NIL)55got-value . msg)) file ((path (mode 420) (:read NIL) (:write NIL) (:create NIL) (:truncate NIL)
57(:append NIL))) nth ((lst n)) cdr ((lst)) / ((n . rest)) newline (((io56(:append NIL))) nth ((lst n)) cdr ((lst)) / ((n . rest)) newline (((io
58*io-out*))) separate-doc-from-body ((body (doc NIL))) cdadar ((lst)) foldr ((fn zero . seqs)) sqrt ((x)) reverse ((lst)) lz-pack ((data57*io-out*))) separate-doc-from-body ((body (doc NIL))) cdadar ((lst)) foldr ((fn zero . seqs)) sqrt ((x)) reverse ((lst)) lz-pack ((data
59(level 0))) *prompt* (NIL) member ((item lst)) bignum? ((v)) fixnum (((n 0))) f64 (((n 0.0))) memq ((item58(level 0))) *prompt* (NIL) member ((item lst)) bignum? ((v)) memq ((item lst)) fixnum (((n
60lst)) str->num ((s (:base NIL))) exp ((p)) caaaar ((lst)) io-column ((io)) traced? ((fn)) cond (clauses) s64 (((n590))) f64 (((n 0.0))) str->num ((s (:base NIL))) exp ((p)) caaaar ((lst)) io-column ((io)) traced? ((fn)) cond (clauses) s64 (((n
610))) io-flush ((io)) assoc ((key lst)) + (rest) path-delete ((path)) cadadr ((lst)) foldr1 ((fn600))) io-flush ((io)) assoc ((key lst)) + (rest) path-delete ((path)) cadadr ((lst)) foldr1 ((fn
62seq)) compare ((a b)) length ((seq)) error (msg) print-exception ((e)) set-top-level-value! ((sym61seq)) compare ((a b)) length ((seq)) error (msg) print-exception ((e)) set-top-level-value! ((sym
63expr)) load ((path/io (eval eval))) getpid (NIL) keyword? ((v)) aref ((sequence subscript0 . rest)) sym? ((v)) defmacro ((form . body)) u64 (((n62expr)) load ((path/io (eval eval))) getpid (NIL) keyword? ((v)) aref ((sequence subscript0 . rest)) sym? ((v)) defmacro ((form . body)) u64 (((n
@@ -66,35 +65,36 @@ tail)) quote ((expr)) nreconc ((lst tail)) defc*r ((name)) read-all-of ((fn · 2 unmodified lines
66new)) div0 ((a n)) set-syntax! ((sym fn)) mod0 ((a n)) last-pair ((lst)) path-cwd (((to NIL))) arr? ((v)) cadaar ((lst)) unwind-protect ((expr65new)) div0 ((a n)) set-syntax! ((sym fn)) mod0 ((a n)) last-pair ((lst)) path-cwd (((to NIL))) arr? ((v)) cadaar ((lst)) unwind-protect ((expr
67finally)) cos ((r)) io-skip ((io offset (:end NIL))) with-bindings ((binds . body)) every ((pred66finally)) cos ((r)) io-skip ((io offset (:end NIL))) with-bindings ((binds . body)) every ((pred
68lst)) atom? ((v)) p64 (((n 0))) str-utf8? ((s)) apply ((f arg . rest)) cddr ((lst)) not ((v)) print (args) letrec ((binds . body)) with-output (((var) . body)67lst)) atom? ((v)) p64 (((n 0))) str-utf8? ((s)) apply ((f arg . rest)) cddr ((lst)) not ((v)) print (args) letrec ((binds . body)) with-output (((var) . body)
69((var io) . body)) cdaar ((lst)) cdar ((lst)) iota ((count (start 0) (step 1))) caaddr ((lst)) environment (NIL) getprop ((symbol68((var io) . body)) cdar ((lst)) cdaar ((lst)) iota ((count (start 0) (step 1))) caaddr ((lst)) environment (NIL) getprop ((symbol
70key (def NIL))) putprop ((symbol key val)) * (rest) repl (NIL) io-read-until ((io r)) get ((table69key (def NIL))) putprop ((symbol key val)) * (rest) repl (NIL) io-read-until ((io r)) get ((table
71key (failed-result))) table? ((v)) u16 (((n 0))) logxor (ints) zip (lst) str-width ((s)) caddr ((lst)) acos ((x)) to-proper ((lst)) time->str ((sec)) table-keys ((ta)) set-doc! ((symbol70key (failed-result))) table? ((v)) u16 (((n 0))) logxor (ints) zip (lst) str-width ((s)) caddr ((lst)) acos ((x)) to-proper ((lst)) time->str ((sec)) table-keys ((ta)) set-doc! ((symbol
72doc-seq . formals-list)) catch ((tag expr)) __start ((argv interactive)) floor ((x)) add-exit-hook ((fn)) str-join ((strlist71doc-seq . formals-list)) catch ((tag expr)) __start ((argv interactive)) floor ((x)) add-exit-hook ((fn)) str-join ((strlist
73sep)) >= ((v . rest)) lognot ((int)) length= ((seq n)) void? ((v)) int? ((v)) nanoseconds-monotonic (NIL) io-discard-buffer ((io)) with-input-from ((io . body)) car ((lst)) <= ((v . rest)) ceiling ((x)) length> ((seq72sep)) >= ((v . rest)) lognot ((int)) void? ((v)) length= ((seq n)) int? ((v)) io-discard-buffer ((io)) nanoseconds-monotonic (NIL) with-input-from ((io . body)) car ((lst)) <= ((v . rest)) arr ((type . rest)) length> ((seq
74n)) arr ((type . rest)) arg-error (msg) asin ((x)) put! ((table key value)) log ((x (base (exp73n)) ceiling ((x)) arg-error (msg) asin ((x)) put! ((table key value)) log ((x (base (exp 1)))) cdaddr ((lst)) ash ((int
751)))) cdaddr ((lst)) ash ((int nbits)) str-sub ((s start (end NIL))) vec-alloc ((length . rest)) arr-alloc ((type74nbits)) str-sub ((s start (end NIL))) arr-alloc ((type length . rest)) vec-alloc ((length . rest)) cddadr ((lst)) memv ((item
76length . rest)) cddadr ((lst)) memv ((item lst)) max ((v . rest)) closure? ((v)) read-all ((io)) help-print-header ((term75lst)) max ((v . rest)) closure? ((v)) read-all ((io)) help-print-header ((term sigs (:kind NIL)
77sigs (:kind NIL) (:lpad ""))) sleep ((sec)) rune? ((v)) s16 (((n 0))) os-setenv ((name value)) __script ((path))) *doc* #table(append "Return the concatenation of the arguments.\n\nLists are copied, except the last one, which becomes the `cdr` of the\nfinal dotted pair. It's returned as is if it was the only argument.\nNo lists are changed in-place." (doc76(:lpad ""))) sleep ((sec)) s16 (((n
770))) rune? ((v)) os-setenv ((name value)) __script ((path))) *doc* #table(append "Return the concatenation of the arguments.\n\nLists are copied, except the last one, which becomes the `cdr` of the\nfinal dotted pair. It's returned as is if it was the only argument.\nNo lists are changed in-place." (doc
78group error) "Errors and exception handling." io-eof? "Return `T` if `io` is currently in the \"end of file\" state, `NIL`\notherwise." path-exists? "Return `T` if `path` exists on the filesystem, `NIL` otherwise." cadddr "Shorthand for (car (cdr (cdr (cdr lst))))." (doc78group error) "Errors and exception handling." io-eof? "Return `T` if `io` is currently in the \"end of file\" state, `NIL`\notherwise." path-exists? "Return `T` if `path` exists on the filesystem, `NIL` otherwise." cadddr "Shorthand for (car (cdr (cdr (cdr lst))))." (doc
79group string) "Strings and runes." sort "Return a copy of the list sorted by comparing elements with the\ntwo-argument function `less-than?`.\n\nAn optional keyworded argument `:key` is used to provide a function to\nretrieve terms (the _key_) from the list items in order to perform\ncomparison. By default the terms compared are the list elements\nthemselves." fixnum? "Return `T` if `v` is of a fixnum type, `NIL` otherwise." exit "Terminate the process with the specified message and code. Does not return.\n\nThe message is expected to be a non-empty string in case of an error.\nThe code is expected to be a positive integer in case of an error." __finish "A function called right before exit by the VM.\n\nThe exit `status` is either `NIL` or a string referring to the error\ncondition." caaar "Shorthand for (car (car (car lst)))." io-peek "Return a value of the specified type by peeking at data of the IO\nobject.\n\nCompared to `io-read`, this function does not consume the data -\nmultiple repeated calls with the same arguments will return the\nsame result.\n\nThe `type` must specify a fixed-width number, pointer or rune.\n\nNumerical values may be peeked at in a specific endianness order\nby setting `endian` to either `:little-endian` or `:big-endian`.\nHost CPU endianness is used if not specified.\n\nIf the parameter `n` is provided, peek `n` values of the type,\nreturning an array of the values or a string when `type` is `utf8`." s32 "Construct a 32-bit signed number." u8 "Construct a 8-bit unsigned number." any "Return `T` if the predicate is true for _any_ element of the list,\n`NIL` otherwise." nthcdr "Return the reminder of the list after at most `n` elements, or `NIL`\nif the list is shorter." os-getenv "Return the value of the environment variable `name` or `NIL` if it's\nnot set." s8 "Construct a 8-bit signed number." tag-of "Return the internal VM tag of the value." io-close "Close the IO object.\n\nNo further operations on the IO object are possible, those will throw\nan exception if attempted. The only exception is `(io-filename io)`,\nwhich might be useful in some cases for debugging purposes." io-line! "Change the current line number of the IO object." num? "Return `T` if `v` is of a numerical type, `NIL` otherwise.\n\nNumerical types include floating point, fixnum, bignum, etc.\nNote: ironically, a NaN value is considered a number by this function\nsince it's only testing the _type_ of the value." unquote-splicing "Evaluate the expression, which is a part of a quasiquoted expression\nitself, and \"splice\" it at the location." +os-name+ "The name of the operating system this StreetLISP VM executable was\nbuilt for.\n\nIt's set to a lowercase string and its value is considered \"best\neffort\" - it might not always be accurate.\n\nPossible values: `\"unknown\"`, `\"plan9\"`, `\"linux\"`, `\"openbsd\"`,\n`\"netbsd\"`, `\"dragonflybsd\"`, `\"freebsd\"`, `\"haiku\"`, `\"macosx\"`,\n`\"macos\"`, `\"dos\"`." assert "Throw an exception if `expr` evaluates to `NIL`. Return `T` in any\nother case." vec->list "Return the vector converted to a list." 1+ "Equivalent to `(+ n 1)` - increment by one." throw "Raise an exception consisting of a tag and a value.\n\nThis exception can be handled directly with `catch`,\nsee `(help catch)`." positive? "Return `T` if `n` is greater than zero. Shorthand for `(> n 0)`." atan "Return the arc tangent of `y/x` in radians." *builtins* "VM instructions as closures." remprop "Remove a property associated with the symbol.\n\nReturns `T` if the property was removed, `NIL` if there was no\nsuch association defined for the symbol." io-copy-until "Copy bytes from the source IO object to the destination until\nencountering the delimiting rune `r` and return the number of bytes\ncopied. The copied bytes include the delimiter." (doc79group string) "Strings and runes." sort "Return a copy of the list sorted by comparing elements with the\ntwo-argument function `less-than?`.\n\nAn optional keyworded argument `:key` is used to provide a function to\nretrieve terms (the _key_) from the list items in order to perform\ncomparison. By default the terms compared are the list elements\nthemselves." fixnum? "Return `T` if `v` is of a fixnum type, `NIL` otherwise." exit "Terminate the process with the specified message and code. Does not return.\n\nThe message is expected to be a non-empty string in case of an error.\nThe code is expected to be a positive integer in case of an error." __finish "A function called right before exit by the VM.\n\nThe exit `status` is either `NIL` or a string referring to the error\ncondition." caaar "Shorthand for (car (car (car lst)))." io-peek "Return a value of the specified type by peeking at data of the IO\nobject.\n\nCompared to `io-read`, this function does not consume the data -\nmultiple repeated calls with the same arguments will return the\nsame result.\n\nThe `type` must specify a fixed-width number, pointer or rune.\n\nNumerical values may be peeked at in a specific endianness order\nby setting `endian` to either `:little-endian` or `:big-endian`.\nHost CPU endianness is used if not specified.\n\nIf the parameter `n` is provided, peek `n` values of the type,\nreturning an array of the values or a string when `type` is `utf8`." s32 "Construct a 32-bit signed number." u8 "Construct a 8-bit unsigned number." any "Return `T` if the predicate is true for _any_ element of the list,\n`NIL` otherwise." nthcdr "Return the reminder of the list after at most `n` elements, or `NIL`\nif the list is shorter." s8 "Construct a 8-bit signed number." os-getenv "Return the value of the environment variable `name` or `NIL` if it's\nnot set." tag-of "Return the internal VM tag of the value." io-close "Close the IO object.\n\nNo further operations on the IO object are possible, those will throw\nan exception if attempted. The only exception is `(io-filename io)`,\nwhich might be useful in some cases for debugging purposes." io-line! "Change the current line number of the IO object." num? "Return `T` if `v` is of a numerical type, `NIL` otherwise.\n\nNumerical types include floating point, fixnum, bignum, etc.\nNote: ironically, a NaN value is considered a number by this function\nsince it's only testing the _type_ of the value." unquote-splicing "Evaluate the expression, which is a part of a quasiquoted expression\nitself, and \"splice\" it at the location." +os-name+ "The name of the operating system this StreetLISP VM executable was\nbuilt for.\n\nIt's set to a lowercase string and its value is considered \"best\neffort\" - it might not always be accurate.\n\nPossible values: `\"unknown\"`, `\"plan9\"`, `\"linux\"`, `\"openbsd\"`,\n`\"netbsd\"`, `\"dragonflybsd\"`, `\"freebsd\"`, `\"haiku\"`, `\"macosx\"`,\n`\"macos\"`, `\"dos\"`." assert "Throw an exception if `expr` evaluates to `NIL`. Return `T` in any\nother case." vec->list "Return the vector converted to a list." 1+ "Equivalent to `(+ n 1)` - increment by one." throw "Raise an exception consisting of a tag and a value.\n\nThis exception can be handled directly with `catch`,\nsee `(help catch)`." positive? "Return `T` if `n` is greater than zero. Shorthand for `(> n 0)`." atan "Return the arc tangent of `y/x` in radians." *builtins* "VM instructions as closures." remprop "Remove a property associated with the symbol.\n\nReturns `T` if the property was removed, `NIL` if there was no\nsuch association defined for the symbol." io-copy-until "Copy bytes from the source IO object to the destination until\nencountering the delimiting rune `r` and return the number of bytes\ncopied. The copied bytes include the delimiter." (doc
80group list) "Working with lists." (doc group compare) "Comparison operators." cdddar "Shorthand for (cdr (cdr (cdr (car lst))))." set-cdr! "Modify a cons cell (a list) in-place by putting `new-second` as its\nsecond element (tail of the list). Return the modified cons\ncell (list)." stacktrace "Return the current stack trace." eq? "Return `T` if `a` and `b` are the same object, `NIL` otherwise." *random-state* "The random state of the current process.\n\nThe state isn't set (is `NIL`) until a call is made to any function\nthat uses it." io->str "Return the data of the in-memory `io` buffer as a string." bound? "Return `T` if `sym` has a value associated with it, `NIL` otherwise." list->vec "Return the list converted to a vector." call-with-values "Call `producer` and pass the values produced as arguments to\n`receiver`." def "Assign the function (first form) or the result of the expression\n(second form) to the identifier.\n\nDocumentation for the definition may also be supplied after `form` in\nthe same manner as with `defdoc` macro (see `(help defdoc)`).\n\nFunction definitions themselves may contain other definitions internal\nto the function." odd? "Return `T` if `n` is an odd integer, `NIL` otherwise." list? "Return `T` if the value is either `NIL` or a cons cell, `NIL`\notherwise." str-rep "Return the concatenation of the `term` formatted as a string, repeated\n`k` times." time "Display the elapsed time of evaluating `expr` to `*io-out*`, return\nthe result of the evaluated expression." size-of "Return the size of the value in bytes, if applicable.\n\nWorks only with C integer types, arrays, strings and in-memory\nbuffers." sym "Return a symbol with the name being the concatenation of terms\nformatted as strings.\n\nThis is equivalent to `(sym (str …))`." tanh "Return the hyperbolic tangent of `x`." for "Call the function `f` with a single argument in a loop until the argument\nreaches `limit` or greater.\n\nThe argument is incremented by `1` after each call, with the initial value\nset to `start`." begin "Evaluate the expressions in order and return the result of the last\nexpression." const? "Return `T` if the term refers to a constant, `NIL` otherwise.\n\nConstants cannot be modified with `set!`. Trying to do so will result\nin an exception." str-trim "Return the portion of the string with all leading runes satisfying\n`lead-pred` (and trailing runes satisfying `trail-pred`) removed.\n\nWithout predicates explicitly specified, `str-trim` will remove\nwhitespace from both sides of the string.\n\nPass `NIL` as the predicate to disable trimming on either side." io-pos! "Change the current absolute position within the IO object in bytes,\nreturn the resulting position." return "Return from the function with the specified value as the result." *stderr* "Standard error output IO stream." tan "Return the tangent of `r`, where `r` is given in radians." table "Construct a table from keys from the arguments.\n\nEvery two arguments are expected to be a key and a value associated\nwith that key." __rcscript "Execute, if exists, the user's \"run commands\" file.\n\nThe file path is predefined and depends on the OS:\n\n * `$home/lib/slrc` on Plan 9\n * `$HOME/.slrc` on other operating systems\n\nIt is automatically loaded by StreetLISP when running in interactive\nmode. The user may wish to use this file to change the look of the\nprompt, load additional functionality they want to use without having\nto do the process manually each time, and so on." doc-group "Define documentation for a group." cdaaar "Shorthand for (cdr (car (car (car lst))))." bounds-error "Raise a bounds error exception." even? "Return `T` if `n` is an even integer, `NIL` otherwise." *properties* "All properties of symbols recorded with `putprop` are in this table." zero? "Return `T` if `n` is zero. Shorthand for `(= n 0)`." proper-list? "Return `T` is the value is a proper list. That is, a non-circular\nlist with the last element being `NIL`, as opposed to a dotted list." random "Return a random number in the range `[0, max]` (inclusive).\n\nThe result is either an integer or a floating point number, depending\non the type of the `max` argument, which has to be a positive number.\n\nOptional `state` can be specified, otherwise the random state of the\ncurrent process (`*random-state*`) is used. State will be modified\nin-place." io-filename! "Change the filename of the IO object, return the new filename.\n\nChanging the filename does not cause any side effects. The filename\nis purely informative and does not necessarily reflect the actual\npath." *directory-separator* "OS-specific path separator.\n\nIt is preferred over hardcoded `\"/\"`, for portability." reverse! "Return the list with its elements in reverse order.\n\nThe original list may be modified by this function since it's a\ndestructive operation." eval "Evaluate expression." cdaadr "Shorthand for (cdr (car (car (cdr lst))))." u32 "Construct a 32-bit unsigned number." cons "Return a cons cell containing two arguments." filter "Return a copy of the list with only the elements of the original\nthat satisfy the predicate." do "Run `commands` sequentially in a loop until the test condition\nevaluates to `NIL`.\n\nEach variable in `vars` consists of the variable's name, its\ninitial value and (optionally) a single \"step\" expression:\n\n (var-name init-value step-expr)\n\nLoop test condition and (optionally) the result expression are\ncontained within `test-spec`:\n\n (test-cond result-exprs)\n\nLoop runs as long as `test-cond` evaluates to `NIL`. If `test-cond`\nis satisfied (result is not `NIL`), loop is terminated and either\nthe result of `result-exprs` is returned or, if `result-exprs` isn't\nsupplied, `#<void>` is used instead.\n\nAfter each loop run, every variable containing a step expression\ngets updated to the the result of that expression, which may reference\nthe variable by its name." make-random-state "Return a new random state.\n\nIf `state` is `NIL`, a copy of the random state of the current process\n(`*random-state*`) is returned. If `state` is `T`, the returned random\nstate is a new one that has been randomly initialized. If an already\nexisting random state is passed, the returned value is a copy of that\nstate." assq "Return a pair of a matching key and the associated value, or `NIL` if\nnone matched. Keys are compared using `eq?`." let "Bind variables and execute a series of expression that use\nthese bindings, return the result of the last expression.\n\nIf a binding in the first form consists of a variable name alone,\nits value is set to `#<void>`.\n\nThe second form `(let id ((… ) …) …)`, which is called\n\"named let\", allows referencing the resulting lambda within\nthe expressions following the bindings to aid with recursive\ncalls." io-buffer-mode! "Changed the output buffering behavior of the writable IO, return the\napplied value.\n\nSee `io-buffer-mode` for supported modes." del! "Remove any existing mapping for `key` and return the table." when "Shorthand for `(if cond body NIL)`.\n\nA non-empty body is required." vec? "Return `T` if `v` is a vector, `NIL` otherwise." min "Return the smallest among the arguments." cddaar "Shorthand for (cdr (cdr (car (car lst))))." help "Display documentation for a specific term or group of terms, if\navailable.\n\nAn optional symbol `group` is used to query for documentation on a\ngroup instead of a single term. All available documentation groups\ncan be displayed with `(help groups)`.\n\nAsterisk can be added to the beginning and/or end of the term in order\nto list the matching terms defined in the current environment. This\ncan be useful to recall a function's name.\n\nRune `↳` followed by an object appearing in the documentation describes\nthe returned value. Rune `‼` follows by what is being written to the\noutput or by an error raised." io? "Return `T` if `term` is of `io` type, `NIL` otherwise." (doc80group list) "Working with lists." (doc group compare) "Comparison operators." cdddar "Shorthand for (cdr (cdr (cdr (car lst))))." set-cdr! "Modify a cons cell (a list) in-place by putting `new-second` as its\nsecond element (tail of the list). Return the modified cons\ncell (list)." stacktrace "Return the current stack trace." eq? "Return `T` if `a` and `b` are the same object, `NIL` otherwise." *random-state* "The random state of the current process.\n\nThe state isn't set (is `NIL`) until a call is made to any function\nthat uses it." io->str "Return the data of the in-memory `io` buffer as a string." bound? "Return `T` if `sym` has a value associated with it, `NIL` otherwise." list->vec "Return the list converted to a vector." def "Assign the function (first form) or the result of the expression\n(second form) to the identifier.\n\nDocumentation for the definition may also be supplied after `form` in\nthe same manner as with `defdoc` macro (see `(help defdoc)`).\n\nFunction definitions themselves may contain other definitions internal\nto the function." call-with-values "Call `producer` and pass the values produced as arguments to\n`receiver`." odd? "Return `T` if `n` is an odd integer, `NIL` otherwise." list? "Return `T` if the value is either `NIL` or a cons cell, `NIL`\notherwise." str-rep "Return the concatenation of the `term` formatted as a string, repeated\n`k` times." time "Display the elapsed time of evaluating `expr` to `*io-out*`, return\nthe result of the evaluated expression." size-of "Return the size of the value in bytes, if applicable.\n\nWorks only with C integer types, arrays, strings and in-memory\nbuffers." sym "Return a symbol with the name being the concatenation of terms\nformatted as strings.\n\nThis is equivalent to `(sym (str …))`." tanh "Return the hyperbolic tangent of `x`." for "Call the function `f` with a single argument in a loop until the argument\nreaches `limit` or greater.\n\nThe argument is incremented by `1` after each call, with the initial value\nset to `start`." begin "Evaluate the expressions in order and return the result of the last\nexpression." const? "Return `T` if the term refers to a constant, `NIL` otherwise.\n\nConstants cannot be modified with `set!`. Trying to do so will result\nin an exception." str-trim "Return the portion of the string with all leading runes satisfying\n`lead-pred` (and trailing runes satisfying `trail-pred`) removed.\n\nWithout predicates explicitly specified, `str-trim` will remove\nwhitespace from both sides of the string.\n\nPass `NIL` as the predicate to disable trimming on either side." io-pos! "Change the current absolute position within the IO object in bytes,\nreturn the resulting position." return "Return from the function with the specified value as the result." *stderr* "Standard error output IO stream." tan "Return the tangent of `r`, where `r` is given in radians." table "Construct a table from keys from the arguments.\n\nEvery two arguments are expected to be a key and a value associated\nwith that key." __rcscript "Execute, if exists, the user's \"run commands\" file.\n\nThe file path is predefined and depends on the OS:\n\n * `$home/lib/slrc` on Plan 9\n * `$HOME/.slrc` on other operating systems\n\nIt is automatically loaded by StreetLISP when running in interactive\nmode. The user may wish to use this file to change the look of the\nprompt, load additional functionality they want to use without having\nto do the process manually each time, and so on." doc-group "Define documentation for a group." cdaaar "Shorthand for (cdr (car (car (car lst))))." bounds-error "Raise a bounds error exception." even? "Return `T` if `n` is an even integer, `NIL` otherwise." *properties* "All properties of symbols recorded with `putprop` are in this table." zero? "Return `T` if `n` is zero. Shorthand for `(= n 0)`." proper-list? "Return `T` is the value is a proper list. That is, a non-circular\nlist with the last element being `NIL`, as opposed to a dotted list." io-filename! "Change the filename of the IO object, return the new filename.\n\nChanging the filename does not cause any side effects. The filename\nis purely informative and does not necessarily reflect the actual\npath." random "Return a random number in the range `[0, max]` (inclusive).\n\nThe result is either an integer or a floating point number, depending\non the type of the `max` argument, which has to be a positive number.\n\nOptional `state` can be specified, otherwise the random state of the\ncurrent process (`*random-state*`) is used. State will be modified\nin-place." *directory-separator* "OS-specific path separator.\n\nIt is preferred over hardcoded `\"/\"`, for portability." reverse! "Return the list with its elements in reverse order.\n\nThe original list may be modified by this function since it's a\ndestructive operation." eval "Evaluate expression." cdaadr "Shorthand for (cdr (car (car (cdr lst))))." u32 "Construct a 32-bit unsigned number." cons "Return a cons cell containing two arguments." filter "Return a copy of the list with only the elements of the original\nthat satisfy the predicate." do "Run `commands` sequentially in a loop until the test condition\nevaluates to `NIL`.\n\nEach variable in `vars` consists of the variable's name, its\ninitial value and (optionally) a single \"step\" expression:\n\n (var-name init-value step-expr)\n\nLoop test condition and (optionally) the result expression are\ncontained within `test-spec`:\n\n (test-cond result-exprs)\n\nLoop runs as long as `test-cond` evaluates to `NIL`. If `test-cond`\nis satisfied (result is not `NIL`), loop is terminated and either\nthe result of `result-exprs` is returned or, if `result-exprs` isn't\nsupplied, `#<void>` is used instead.\n\nAfter each loop run, every variable containing a step expression\ngets updated to the the result of that expression, which may reference\nthe variable by its name." assq "Return a pair of a matching key and the associated value, or `NIL` if\nnone matched. Keys are compared using `eq?`." io-buffer-mode! "Changed the output buffering behavior of the writable IO, return the\napplied value.\n\nSee `io-buffer-mode` for supported modes." let "Bind variables and execute a series of expression that use\nthese bindings, return the result of the last expression.\n\nIf a binding in the first form consists of a variable name alone,\nits value is set to `#<void>`.\n\nThe second form `(let id ((… ) …) …)`, which is called\n\"named let\", allows referencing the resulting lambda within\nthe expressions following the bindings to aid with recursive\ncalls." make-random-state "Return a new random state.\n\nIf `state` is `NIL`, a copy of the random state of the current process\n(`*random-state*`) is returned. If `state` is `T`, the returned random\nstate is a new one that has been randomly initialized. If an already\nexisting random state is passed, the returned value is a copy of that\nstate." del! "Remove any existing mapping for `key` and return the table." when "Shorthand for `(if cond body NIL)`.\n\nA non-empty body is required." vec? "Return `T` if `v` is a vector, `NIL` otherwise." min "Return the smallest among the arguments." cddaar "Shorthand for (cdr (cdr (car (car lst))))." help "Display documentation for a specific term or group of terms, if\navailable.\n\nAn optional symbol `group` is used to query for documentation on a\ngroup instead of a single term. All available documentation groups\ncan be displayed with `(help groups)`.\n\nAsterisk can be added to the beginning and/or end of the term in order\nto list the matching terms defined in the current environment. This\ncan be useful to recall a function's name.\n\nRune `↳` followed by an object appearing in the documentation describes\nthe returned value. Rune `‼` follows by what is being written to the\noutput or by an error raised." io? "Return `T` if `term` is of `io` type, `NIL` otherwise." (doc
81group array) "Arrays and vectors." num->str "Return the number formatted as a string.\n\nFloating point numbers can only be formatted in base 10. Bignums are\nsupported with bases 2, 4, 8, 10, 16 and 32. The rest of the\nnumerical types are valid for any base from 2 to 36.\n\nNote: unlike other LISP dialects, StreetLISP's base-32 encoding is\ndone according to RFC 4648." unquote-nsplicing "Evaluate the expression, which is a part of a quasiquoted expression\nitself, and \"splice\" it at the location.\n\nUnlike `unquote-splicing`, this macro may operate destructively\non the list produced." mod "Return the remainder of the Euclidean division `a/n`." if "Return the result of `then` if `cond` evaluated as \"true\", `else`\notherwise.\n\nThe `else` is not optional unlike in many other LISP implementations.\nPrimary purpose is to spot errors involving wrong parenthesis\nplacement. Another reason is to force a certain code style." str-pad "Return the string padded until the given length.\n\nBy default the string is padded with spaces on the right." p32 "Construct a 32-bit abstract pointer value." case "Evaluate an expression, select one of the clauses by matching\nthe result with `eqv?`, and return the result of the clause.\n\nThe special `else` clause matching expression, if specified, is\nused as a fallback if none of the clauses matched the result.\nIf no `else` was specified and no matches occured, `NIL` is\nreturned." io-read-lines "Return a list of lines read from the IO object until it ran out of\ndata.\n\nThe file is split into lines by `#\\linefeed`. Each string will have\nthe character, except the last line if EOF has been reached\nbeforehand." io-line "Return the current line number of the IO object.\n\nLine number is purely informative and is only being automatically\nupdated with the files opened for reading. If the cursor position is\nchanged via `io-skip` or `io-pos!`, the behavior is undefined." zip-with "Return a list where each nth element is the result of the supplied\nfunction applied to the corresponding elements from the parameter lists.\n\nThe resulting list is as long as the shortest of the arguments." trycatch "Return the result of evaluation of the expression `try` or, if an\nexception has been thrown, the one-argument function `catch`." (doc81group array) "Arrays and vectors." num->str "Return the number formatted as a string.\n\nFloating point numbers can only be formatted in base 10. Bignums are\nsupported with bases 2, 4, 8, 10, 16 and 32. The rest of the\nnumerical types are valid for any base from 2 to 36.\n\nNote: unlike other LISP dialects, StreetLISP's base-32 encoding is\ndone according to RFC 4648." unquote-nsplicing "Evaluate the expression, which is a part of a quasiquoted expression\nitself, and \"splice\" it at the location.\n\nUnlike `unquote-splicing`, this macro may operate destructively\non the list produced." mod "Return the remainder of the Euclidean division `a/n`." if "Return the result of `then` if `cond` evaluated as \"true\", `else`\notherwise.\n\nThe `else` is not optional unlike in many other LISP implementations.\nPrimary purpose is to spot errors involving wrong parenthesis\nplacement. Another reason is to force a certain code style." str-pad "Return the string padded until the given length.\n\nBy default the string is padded with spaces on the right." p32 "Construct a 32-bit abstract pointer value." case "Evaluate an expression, select one of the clauses by matching\nthe result with `eqv?`, and return the result of the clause.\n\nThe special `else` clause matching expression, if specified, is\nused as a fallback if none of the clauses matched the result.\nIf no `else` was specified and no matches occured, `NIL` is\nreturned." io-read-lines "Return a list of lines read from the IO object until it ran out of\ndata.\n\nThe file is split into lines by `#\\linefeed`. Each string will have\nthe character, except the last line if EOF has been reached\nbeforehand." io-line "Return the current line number of the IO object.\n\nLine number is purely informative and is only being automatically\nupdated with the files opened for reading. If the cursor position is\nchanged via `io-skip` or `io-pos!`, the behavior is undefined." zip-with "Return a list where each nth element is the result of the supplied\nfunction applied to the corresponding elements from the parameter lists.\n\nThe resulting list is as long as the shortest of the arguments." trycatch "Return the result of evaluation of the expression `try` or, if an\nexception has been thrown, the one-argument function `catch`." (doc
82group builtin) "Built-in operators." macrocall? "Return the macro application function if `e` refers to a macro call,\n`NIL` otherwise." iterate "Return the list of length `n` containing results of applying function\n`fn` to `zero`, 0 through `n` times.\n\nThe result is of form\n\n [zero (fn zero) (fn (fn zero)) (fn (fn (fn zero))) …]" *syntax-environment* "Table containing macro definitions.\n\nThe keys are macro names, the values are their application functions." builtin "Return the builtin associated with the symbol.\n\nThrows an exception if no such builtin exists." table-values "Return the list of all values of the table." macroexpand "Return a fully macro-expanded expression.\n\nExpansion will continue until no more macro calls are left." caadr "Shorthand for (car (car (cdr lst)))." type-of "Return the underlying type of the value." top-level-value "Return the value bound to the symbol in the top level (global)\nenvironment." defstruct "Declare a new structure type with the specified name and slots.\n\nThe default underlying type is a \"named\" vector (`:type vec`), where\nthe first element is the name of the structure's type, the rest are\nthe keyworded slot values. A list with slot values alone can be used\ninstead by adding `:type list` option. The list will not contain the\nname of the struct by default, which can be enabled with `:named T`\noption.\n\nAs an example, the following declaration generates the default\nconstructor for a structure of three slots, with one of them (`c`)\nhaving a non-`NIL` default value and marked as read-only:\n\n (defstruct blah \"Return stuff.\" :doc-group stuff a b (c 1 :read-only T))\n ; (make-blah (:a NIL) (:b NIL) (:c 1))\n ; (blah-a s)\n ; (blah-b s)\n ; (blah-c s)\n ; (blah-a! s new-a)\n ; (blah-b! s new-b)\n\nSlot's options, if any, should be specified after its default value.\nSupported options are:\n\n ; mark the slot as read-only\n ; its value can be read, but trying to modify it will throw an error\n … :read-only T\n\nThe constructor can be changed in several ways:\n\n ; disable the constructor altogether\n (defstruct blah :constructor NIL a b c)\n ; only change its name\n (defstruct blah :constructor blargh a b c)\n ; rename AND avoid using keywords\n (defstruct blah :constructor (blah a b c) a b c)\n\nThe option `:conc-name` specifies the slot accessor/setter prefix,\nwhich defaults to `structname-`. Prefix can be disabled entirely with\n`:conc-name NIL`.\n\nSlot setters are generated for writable slots by appending `!`\n(exclamation mark) to the accessor's name.\n\nDefault predicate can be disabled or its name, which defaults to\n`structname?`, changed:\n\n ; use \"blargh?\" instead of \"blah?\"\n (defstruct blah :predicate blargh? a b c)\n ; without predicate\n (defstruct blah :predicate NIL a b c)" caadar "Shorthand for (car (car (cdr (car lst))))." foldl1 "Same as `foldl` but using the first element of the sequence as the\ninitial accumulator." buffer "Return an in-memory buffer for I/O, of `io` type.\n\nIn the first form an empty buffer for both reading and writing is returned.\n\nA read-only buffer pointing at the underlying data of `v` is returned in\nthe second form. Optionally, the range of the data (measured in bytes)\navailable when accessing the buffer may be limited by using `:start` and/or\n`:end` keyworded arguments." random-state? "Return `T` if the argument is a random state object, `NIL` otherwise." assoc-list "Construct an association list from the arguments.\n\nEvery two arguments are expected to be a key and a value associated\nwith that key." builtin? "Return `T` if `v` is a built-in function implemented in C, `NIL`\notherwise." with-input "Evaluate expressions in `body` with `var` bound to a readable buffer\ncontaining the result of the expression during the evaluation.\n\nOptionally, the range of the data (measured in bytes) available\nwhen accessing the buffer may be limited by using `:start` and/or\n`:end` keyworded arguments.\n\nThe result returned will be that of the last expression in the `body`." str-map "Return the concatenation of the values produced by `fn` when applying\nto each rune of the string `s`.\n\nFunction `fn` may return a value of any type suitable for `io-write` -\na rune, string, array of C primitives. If `fn` returns `NIL`, the\nrune is ignored." macroexpand-1 "Return a macro-expanded expression.\n\nIf the expression is not a macro call, it is returned unchanged.\nOnly a single level of expansion is performed." +endianness+ "Endianess of the CPU the VM is running on, a constant.\n\nSet to either `:big-endian` or `:little-endian`." remove-duplicates "Return a copy of the list with duplicated elements removed.\n\nElements are tested for duplicates using `equal?`. The order of the\nelements is preserved in the resulting list." with-exception-bindings "Bind `*print-…` variables to their `*exception-print-…` counterparts\nevaluate the body." str "Return concatenation of terms formatted as strings.\n\nThis is equivalent to `(princ terms…)`, except the string is\n_returned_, rather than printed." negative? "Return `T` if `n` is a negative number. Shorthand for `(< n 0)`." void "Return the constant `#<void>` while ignoring any arguments.\n\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." io-read-line "Return a single line of input read from `io`.\n\nReading stops at either a `#\\linefeed` character or upon reaching EOF.\nThe line feed character is included in the returned value unless EOF\nhas been reached beforehand.\n\nEOF (`#<eof>`) is returned if the IO object had no data." assert-fail "Throw an \"assertion failed\" exception if evaluating `expr` itself does\nnot result in an exception thrown. Return `T` otherwise.\n\nTo test for a specific exception type, an optional `what` argument can\nbe used." and "Return `NIL` and stop evaluating the arguments if one of them\nevaluated to `NIL`. Return the last value otherwise." 1- "Equivalent to `(- n 1)` - decrement by one." io-buffer-mode "Return the output buffering mode of the writable IO.\n\nPossible values include:\n\n* `NIL` - no buffering, data is written immediately\n* `:line` - data is written when `#\\newline` is encountered\n* `:block` - data is written when the buffer is full\n* `:memory` - the IO is an in-memory buffer itself" that "The result of the last expression evaluated in the REPL." (doc82group builtin) "Built-in operators." macrocall? "Return the macro application function if `e` refers to a macro call,\n`NIL` otherwise." iterate "Return the list of length `n` containing results of applying function\n`fn` to `zero`, 0 through `n` times.\n\nThe result is of form\n\n [zero (fn zero) (fn (fn zero)) (fn (fn (fn zero))) …]" *syntax-environment* "Table containing macro definitions.\n\nThe keys are macro names, the values are their application functions." builtin "Return the builtin associated with the symbol.\n\nThrows an exception if no such builtin exists." table-values "Return the list of all values of the table." macroexpand "Return a fully macro-expanded expression.\n\nExpansion will continue until no more macro calls are left." caadr "Shorthand for (car (car (cdr lst)))." type-of "Return the underlying type of the value." top-level-value "Return the value bound to the symbol in the top level (global)\nenvironment." defstruct "Declare a new structure type with the specified name and slots.\n\nThe default underlying type is a \"named\" vector (`:type vec`), where\nthe first element is the name of the structure's type, the rest are\nthe keyworded slot values. A list with slot values alone can be used\ninstead by adding `:type list` option. The list will not contain the\nname of the struct by default, which can be enabled with `:named T`\noption.\n\nAs an example, the following declaration generates the default\nconstructor for a structure of three slots, with one of them (`c`)\nhaving a non-`NIL` default value and marked as read-only:\n\n (defstruct blah \"Return stuff.\" :doc-group stuff a b (c 1 :read-only T))\n ; (make-blah (:a NIL) (:b NIL) (:c 1))\n ; (blah-a s)\n ; (blah-b s)\n ; (blah-c s)\n ; (blah-a! s new-a)\n ; (blah-b! s new-b)\n\nSlot's options, if any, should be specified after its default value.\nSupported options are:\n\n ; mark the slot as read-only\n ; its value can be read, but trying to modify it will throw an error\n … :read-only T\n\nThe constructor can be changed in several ways:\n\n ; disable the constructor altogether\n (defstruct blah :constructor NIL a b c)\n ; only change its name\n (defstruct blah :constructor blargh a b c)\n ; rename AND avoid using keywords\n (defstruct blah :constructor (blah a b c) a b c)\n\nThe option `:conc-name` specifies the slot accessor/setter prefix,\nwhich defaults to `structname-`. Prefix can be disabled entirely with\n`:conc-name NIL`.\n\nSlot setters are generated for writable slots by appending `!`\n(exclamation mark) to the accessor's name.\n\nDefault predicate can be disabled or its name, which defaults to\n`structname?`, changed:\n\n ; use \"blargh?\" instead of \"blah?\"\n (defstruct blah :predicate blargh? a b c)\n ; without predicate\n (defstruct blah :predicate NIL a b c)" caadar "Shorthand for (car (car (cdr (car lst))))." foldl1 "Same as `foldl` but using the first element of the sequence as the\ninitial accumulator." buffer "Return an in-memory buffer for I/O, of `io` type.\n\nIn the first form an empty buffer for both reading and writing is returned.\n\nA read-only buffer pointing at the underlying data of `v` is returned in\nthe second form. Optionally, the range of the data (measured in bytes)\navailable when accessing the buffer may be limited by using `:start` and/or\n`:end` keyworded arguments." random-state? "Return `T` if the argument is a random state object, `NIL` otherwise." assoc-list "Construct an association list from the arguments.\n\nEvery two arguments are expected to be a key and a value associated\nwith that key." builtin? "Return `T` if `v` is a built-in function implemented in C, `NIL`\notherwise." with-input "Evaluate expressions in `body` with `var` bound to a readable buffer\ncontaining the result of the expression during the evaluation.\n\nOptionally, the range of the data (measured in bytes) available\nwhen accessing the buffer may be limited by using `:start` and/or\n`:end` keyworded arguments.\n\nThe result returned will be that of the last expression in the `body`." str-map "Return the concatenation of the values produced by `fn` when applying\nto each rune of the string `s`.\n\nFunction `fn` may return a value of any type suitable for `io-write` -\na rune, string, array of C primitives. If `fn` returns `NIL`, the\nrune is ignored." macroexpand-1 "Return a macro-expanded expression.\n\nIf the expression is not a macro call, it is returned unchanged.\nOnly a single level of expansion is performed." +endianness+ "Endianess of the CPU the VM is running on, a constant.\n\nSet to either `:big-endian` or `:little-endian`." remove-duplicates "Return a copy of the list with duplicated elements removed.\n\nElements are tested for duplicates using `equal?`. The order of the\nelements is preserved in the resulting list." with-exception-bindings "Bind `*print-…` variables to their `*exception-print-…` counterparts\nevaluate the body." str "Return concatenation of terms formatted as strings.\n\nThis is equivalent to `(princ terms…)`, except the string is\n_returned_, rather than printed." negative? "Return `T` if `n` is a negative number. Shorthand for `(< n 0)`." void "Return the constant `#<void>` while ignoring any arguments.\n\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." io-read-line "Return a single line of input read from `io`.\n\nReading stops at either a `#\\linefeed` character or upon reaching EOF.\nThe line feed character is included in the returned value unless EOF\nhas been reached beforehand.\n\nEOF (`#<eof>`) is returned if the IO object had no data." assert-fail "Throw an \"assertion failed\" exception if evaluating `expr` itself does\nnot result in an exception thrown. Return `T` otherwise.\n\nTo test for a specific exception type, an optional `what` argument can\nbe used." and "Return `NIL` and stop evaluating the arguments if one of them\nevaluated to `NIL`. Return the last value otherwise." 1- "Equivalent to `(- n 1)` - decrement by one." io-buffer-mode "Return the output buffering mode of the writable IO.\n\nPossible values include:\n\n* `NIL` - no buffering, data is written immediately\n* `:line` - data is written when `#\\newline` is encountered\n* `:block` - data is written when the buffer is full\n* `:memory` - the IO is an in-memory buffer itself" that "The result of the last expression evaluated in the REPL." (doc
83group prop) "Dealing with properties of symbols." equal? "Return `T` if both `a` and `b` are of the same value. For non-leaf\ntypes (cons cell and vector), the equality test is performed\nthroughout the whole structure of the values." unquote "Evaluate the expression, which is a part of a quasiquoted expression\nitself, and insert it at the location." (doc83group prop) "Dealing with properties of symbols." equal? "Return `T` if both `a` and `b` are of the same value. For non-leaf\ntypes (cons cell and vector), the equality test is performed\nthroughout the whole structure of the values." unquote "Evaluate the expression, which is a part of a quasiquoted expression\nitself, and insert it at the location." (doc
84group vm) "VM-related functions." *interactive* "Variable indicating whether VM is running in \"interactive\" mode (`T`,\nREPL is active) or not (`NIL`, REPL is not active).\n\nInteractive mode can be forced by adding `-i` as the first command\nline argument." or "Return the first evaluated argument that is not `NIL` and stop\nevaluating the rest of the arguments. Return `NIL` otherwise." cddar "Shorthand for (cdr (cdr (car lst)))." = "Numerical equality test. Return `T` if all numbers are equal,\n`NIL` otherwise." fn? "Return `T` if `v` is a function, `NIL` otherwise." (doc84group vm) "VM-related functions." *interactive* "Variable indicating whether VM is running in \"interactive\" mode (`T`,\nREPL is active) or not (`NIL`, REPL is not active).\n\nInteractive mode can be forced by adding `-i` as the first command\nline argument." or "Return the first evaluated argument that is not `NIL` and stop\nevaluating the rest of the arguments. Return `NIL` otherwise." cddar "Shorthand for (cdr (cdr (car lst)))." = "Numerical equality test. Return `T` if all numbers are equal,\n`NIL` otherwise." fn? "Return `T` if `v` is a function, `NIL` otherwise." (doc
85group type) "Dealing with types." caaadr "Shorthand for (car (car (car (cdr lst))))." make-system-image "Build and store a \"system image\" of the runtime environment to a file." subseq "Return a bounded part of a sequence.\n\nThe returned value is always a copy of the subsequence of the\noriginal. It is an error if either `start` or `end` (if specified)\nare out of bounds." set! "Evaluate the expression, assign the result to the identifier and\nreturn the value.\n\nThe identifier must already be bound in the same environment,\notherwise this results in a compilation error.\n\nMultiple identifiers and expressions may be specified in pairs. The\nreturned value will be the result of the last expression." vm-stats "Print various VM-related information, such as the number of GC\ncalls so far, heap and stack size, etc." ptr "Construct an abstract pointer value. The bit width is either 32-bit\nor 64-bit, depending on the platform the code is executing on.\n\nNote: certain arithmetic operations on pointers, such as division and\nmultiplication, will throw an error. This is done on purpose since\ndoing that on pointers rarely makes sense." caddar "Shorthand for (car (cdr (cdr (car lst))))." print-stack-trace "Print the stacktrace." *stdin* "Standard input IO stream." cosh "Return the hyperbolic cosine of `x`." values "Return the supplied values as multiple-return values." < "Return `T` if the arguments are in strictly increasing order (next\none is greater than the previous one). With a single argument\nthe result is always `T`." (doc85group type) "Dealing with types." caaadr "Shorthand for (car (car (car (cdr lst))))." make-system-image "Build and store a \"system image\" of the runtime environment to a file." subseq "Return a bounded part of a sequence.\n\nThe returned value is always a copy of the subsequence of the\noriginal. It is an error if either `start` or `end` (if specified)\nare out of bounds." set! "Evaluate the expression, assign the result to the identifier and\nreturn the value.\n\nThe identifier must already be bound in the same environment,\notherwise this results in a compilation error.\n\nMultiple identifiers and expressions may be specified in pairs. The\nreturned value will be the result of the last expression." vm-stats "Print various VM-related information, such as the number of GC\ncalls so far, heap and stack size, etc." ptr "Construct an abstract pointer value. The bit width is either 32-bit\nor 64-bit, depending on the platform the code is executing on.\n\nNote: certain arithmetic operations on pointers, such as division and\nmultiplication, will throw an error. This is done on purpose since\ndoing that on pointers rarely makes sense." caddar "Shorthand for (car (cdr (cdr (car lst))))." print-stack-trace "Print the stacktrace." *stdin* "Standard input IO stream." cosh "Return the hyperbolic cosine of `x`." values "Return the supplied values as multiple-return values." < "Return `T` if the arguments are in strictly increasing order (next\none is greater than the previous one). With a single argument\nthe result is always `T`." (doc
86group time) "Measuring, manipulating and displaying time." copy-tree "Return a recursive copy of the list.\n\nUnlike `copy-list`, this function copies subelements of the list\nrecursively." f32 "Construct a 32-bit floating point number." sin "Return the sine of `r`, where `r` is given in radians." io-copy "Copy bytes from the source IO object to the destination and return\nthe number of bytes copied. If `n` is provided, copy up to that many\nbytes." > "Return `T` if the arguments are in strictly decreasing order (previous\none is greater than the next one)." str-rune "Return the nth rune of the string.\n\nThrows an exception if the index `n` is out of bounds." foldl "Reduce the sequences to a single value by repeatedly applying the\nfunction left-associatively.\n\nThe function should be of the form `(fn e₀ e₁ … eₙ acc)`. For each\niteration each `eᵢ` will be set to successive values of the i'th\nsequence. The value `acc` will initially be set to `zero` and\nsubsequently to the previous value of the function application.\n\nThe iteration will terminate once the shortest sequence is exhausted.\n\nFor example, for two sequences (e₀ e₁ … eₙ) and (d₀ d₁ … dₙ), the\nresult will be:\n\n (fn eₙ dₙ (…(fn e₁ d₁ (fn e₀ d₀ zero))…))\n\nNote that `foldl` is tail call recursive." +os-version+ "The \"version\" of the operating system StreetLISP VM is running on.\n\nThe availability of the constant and its value depends on the\noperating system and is only provided for the user to see. No logic\nshould depend on it." abs "Return absolute value of the argument." with-output-to "Evaluate expressions in `body` with `*io-out*` set to `io` during the\nevaluation." *linefeed* "OS-specific _line_ _feed_ value.\n\nIt is preferred over hardcoded `\"\\n\"`, for portability." str? "Return `T` if the argument is a string, `NIL` otherwise." cons? "Return `T` if `v` is a cons cell, `NIL` otherwise." str-split "Return a list of substrings of `str` by splitting at any character in\nthe string `sep`. The splitting characters are removed.\n\nBy default the string is split on space, line feed (newline),\nhorizontal and vertical tab, and form feed.\n\nTrim removes empty strings from the list." io-read "Return a value of the specified type by reading it from the IO\nobject.\n\nThe `type` must specify a fixed-width number, pointer or rune.\n\nNumerical values may be read in a specific endianness order by setting\n`endian` to either `:little-endian` or `:big-endian`. Host CPU\nendianness is used if not specified.\n\nIf the parameter `n` is provided, read `n` values of the type,\nreturning an array of the values or a string when `type` is `utf8`." truncate "Return the integer value of `x` rounded toward zero.\n\nIf `x` is already an integer (or infinite, or NaN), result is `x`." aset! "Modify the sequence element specified by the subscripts and return the\nnew value. The sequence can be an array, vector, a list.\nMulti-dimensional sequences of variating types are also supported." - "Return the result of subtraction. With only one argument a\nnegation is performed." io-truncate "Truncate the underlying IO object to the specified number of bytes." makunbound "Make the symbol unbound." quasiquote "Same as `'expr` but allows evaluating (\"unquoting\") parts of\nthe expression." io-column! "Change the current column number of the IO object." copy-list "Return a copy of the list.\n\nThe number of elements to be copied can be limited with the optional\nargument `n`." logand "Return the result of bitwise AND operation on integers." time-now "Return the number of nanoseconds since Epoch (1970-01-01 00:00:00).\n\nThis measures the system-wide real (wall-clock) time." sinh "Return the hyperbolic sine of `x`." *argv* "The list of command line arguments.\n\nIf StreetLISP was started in interactive mode without a file specified\nfor execution, `*argv*` will be a list containing just one value - the\nname of the `sl` executable.\n\nOtherwise, the file specified for execution and the rest of the remaining\narguments will form the `*argv*` list.\n\nStreetLISP's own options, such as `-i` and `-H ...` will be stripped\nout in any case." top-level-exception-handler "Print the exception `e` and the stack trace to `*stderr*`.\n\nThis is the top level exception handler that is used by `load` and\n`repl` functions to handle exceptions that weren't handled at the\nlower level." identity "Return `v`." untrace "Disable tracing for the function bound to the symbol." count "Return the number of elements in the list that satisfy the predicate." io-pos "Return the current absolute position within the IO object in bytes." +most-positive-fixnum+ "A constant integer closest to positive infinity that can be\nrepresented by fixnum type on this particular platform." map-int "Return a list of elements generated by repeated calls to `fn`.\n\nThe lambda `fn` will be called with a single argument which is an\nincreasing number in the range `[0, count)` (exclusive). The\nresulting list contains the values returned by `fn`." table->assoc-list "Return the table converted to an association list (pairs of each\nkey and value)." length< "Shorthand for a bounded length test `(< (length seq) n)`." unless "Shorthand for `(if cond NIL body)`.\n\nA non-empty body is required." str->time "Return the number of nanoseconds since Epoch from a time and date\nformatted as a string.\n\nBecause the supported format is limited, the returned value will have\nprecision in seconds at most." get-syntax "Return a macro application function based on its name, or `NIL` if\nit's not defined." (doc86group time) "Measuring, manipulating and displaying time." copy-tree "Return a recursive copy of the list.\n\nUnlike `copy-list`, this function copies subelements of the list\nrecursively." f32 "Construct a 32-bit floating point number." sin "Return the sine of `r`, where `r` is given in radians." io-copy "Copy bytes from the source IO object to the destination and return\nthe number of bytes copied. If `n` is provided, copy up to that many\nbytes." > "Return `T` if the arguments are in strictly decreasing order (previous\none is greater than the next one)." str-rune "Return the nth rune of the string.\n\nThrows an exception if the index `n` is out of bounds." foldl "Reduce the sequences to a single value by repeatedly applying the\nfunction left-associatively.\n\nThe function should be of the form `(fn e₀ e₁ … eₙ acc)`. For each\niteration each `eᵢ` will be set to successive values of the i'th\nsequence. The value `acc` will initially be set to `zero` and\nsubsequently to the previous value of the function application.\n\nThe iteration will terminate once the shortest sequence is exhausted.\n\nFor example, for two sequences (e₀ e₁ … eₙ) and (d₀ d₁ … dₙ), the\nresult will be:\n\n (fn eₙ dₙ (…(fn e₁ d₁ (fn e₀ d₀ zero))…))\n\nNote that `foldl` is tail call recursive." +os-version+ "The \"version\" of the operating system StreetLISP VM is running on.\n\nThe availability of the constant and its value depends on the\noperating system and is only provided for the user to see. No logic\nshould depend on it." abs "Return absolute value of the argument." with-output-to "Evaluate expressions in `body` with `*io-out*` set to `io` during the\nevaluation." *linefeed* "OS-specific _line_ _feed_ value.\n\nIt is preferred over hardcoded `\"\\n\"`, for portability." str? "Return `T` if the argument is a string, `NIL` otherwise." cons? "Return `T` if `v` is a cons cell, `NIL` otherwise." io-read "Return a value of the specified type by reading it from the IO\nobject.\n\nThe `type` must specify a fixed-width number, pointer or rune.\n\nNumerical values may be read in a specific endianness order by setting\n`endian` to either `:little-endian` or `:big-endian`. Host CPU\nendianness is used if not specified.\n\nIf the parameter `n` is provided, read `n` values of the type,\nreturning an array of the values or a string when `type` is `utf8`." str-split "Return a list of substrings of `str` by splitting at any character in\nthe string `sep`. The splitting characters are removed.\n\nBy default the string is split on space, line feed (newline),\nhorizontal and vertical tab, and form feed.\n\nTrim removes empty strings from the list." truncate "Return the integer value of `x` rounded toward zero.\n\nIf `x` is already an integer (or infinite, or NaN), result is `x`." aset! "Modify the sequence element specified by the subscripts and return the\nnew value. The sequence can be an array, vector, a list.\nMulti-dimensional sequences of variating types are also supported." - "Return the result of subtraction. With only one argument a\nnegation is performed." io-truncate "Truncate the underlying IO object to the specified number of bytes." makunbound "Make the symbol unbound." quasiquote "Same as `'expr` but allows evaluating (\"unquoting\") parts of\nthe expression." io-column! "Change the current column number of the IO object." copy-list "Return a copy of the list.\n\nThe number of elements to be copied can be limited with the optional\nargument `n`." logand "Return the result of bitwise AND operation on integers." time-now "Return the number of nanoseconds since Epoch (1970-01-01 00:00:00).\n\nThis measures the system-wide real (wall-clock) time." sinh "Return the hyperbolic sine of `x`." *argv* "The list of command line arguments.\n\nIf StreetLISP was started in interactive mode without a file specified\nfor execution, `*argv*` will be a list containing just one value - the\nname of the `sl` executable.\n\nOtherwise, the file specified for execution and the rest of the remaining\narguments will form the `*argv*` list.\n\nStreetLISP's own options, such as `-i` and `-H ...` will be stripped\nout in any case." top-level-exception-handler "Print the exception `e` and the stack trace to `*stderr*`.\n\nThis is the top level exception handler that is used by `load` and\n`repl` functions to handle exceptions that weren't handled at the\nlower level." identity "Return `v`." untrace "Disable tracing for the function bound to the symbol." count "Return the number of elements in the list that satisfy the predicate." io-pos "Return the current absolute position within the IO object in bytes." +most-positive-fixnum+ "A constant integer closest to positive infinity that can be\nrepresented by fixnum type on this particular platform." map-int "Return a list of elements generated by repeated calls to `fn`.\n\nThe lambda `fn` will be called with a single argument which is an\nincreasing number in the range `[0, count)` (exclusive). The\nresulting list contains the values returned by `fn`." table->assoc-list "Return the table converted to an association list (pairs of each\nkey and value)." length< "Shorthand for a bounded length test `(< (length seq) n)`." unless "Shorthand for `(if cond NIL body)`.\n\nA non-empty body is required." str->time "Return the number of nanoseconds since Epoch from a time and date\nformatted as a string.\n\nBecause the supported format is limited, the returned value will have\nprecision in seconds at most." get-syntax "Return a macro application function based on its name, or `NIL` if\nit's not defined." (doc
87group table) "Tables of keys with associated values." ptr? "Return `T` if the argument is an abstract pointer, `NIL` otherwise." expt "Return the value of `x` raised to the power of `p`." io-read-all "Return a string containing all of the data read from the IO object\nuntil it ran out of data.\n\nAn empty string (`\"\"`) is returned if the IO object had no data." gc "Force a garbage collection run.\n\nOne does not need to execute this function manually since garbage\ncollection will happen automatically, based on the amount of data\nallocated." io-write "Write the value to the IO object, return the number of bytes written.\n\nThe value may be a string, a fixed-width number or pointer, a rune\nor an array.\n\nNumerical values may be written in a specific endianness order by\nsetting `endian` to either `:little-endian` or `:big-endian`. Host\nCPU endianness is used if not specified.\n\nWhen writing a rune or an array of runes, they will be converted and\nwritten as an UTF-8 string." table-invert "Return a new table with the keys and values from the original table\nbut entries _inverted_ - values to keys and keys to values.\n\nNote that if the original table had several keys mapped to the same\nvalue, only one such mapping will be stored in the new table." lz-unpack "Return decompressed data previously compressed using lz-pack.\n\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." div "Return the quotient of the Euclidean division `a/n`." princ "Print the arguments to *io-out* with `*print-readably*` set to `NIL`." (doc87group table) "Tables of keys with associated values." ptr? "Return `T` if the argument is an abstract pointer, `NIL` otherwise." expt "Return the value of `x` raised to the power of `p`." io-read-all "Return a string containing all of the data read from the IO object\nuntil it ran out of data.\n\nAn empty string (`\"\"`) is returned if the IO object had no data." gc "Force a garbage collection run.\n\nOne does not need to execute this function manually since garbage\ncollection will happen automatically, based on the amount of data\nallocated." io-write "Write the value to the IO object, return the number of bytes written.\n\nThe value may be a string, a fixed-width number or pointer, a rune\nor an array.\n\nNumerical values may be written in a specific endianness order by\nsetting `endian` to either `:little-endian` or `:big-endian`. Host\nCPU endianness is used if not specified.\n\nWhen writing a rune or an array of runes, they will be converted and\nwritten as an UTF-8 string." table-invert "Return a new table with the keys and values from the original table\nbut entries _inverted_ - values to keys and keys to values.\n\nNote that if the original table had several keys mapped to the same\nvalue, only one such mapping will be stored in the new table." lz-unpack "Return decompressed data previously compressed using lz-pack.\n\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." div "Return the quotient of the Euclidean division `a/n`." princ "Print the arguments to *io-out* with `*print-readably*` set to `NIL`." (doc
88group struct) "Declaring and manipulating structures." last-cdr "Return the second element of the last cell in the list.\n\nIt will always evaluate to `NIL` with any proper list." trace "Enable tracing for the function bound to the symbol.\n\nWhen tracing is enabled for the function, before evaluating the call\nthe name and arguments will be printed to `*io-out*`." io-filename "Return the filename of the IO object." let* "Same as the first form of `let` but each of the binding\nexpressions may reference any of the varibles bound previously.\n\nIf a binding consists of a variable name alone, its value is\nset to `#<void>`." gensym? "Return `T` if the argument is a gensym, `NIL` otherwise." (doc88group struct) "Declaring and manipulating structures." last-cdr "Return the second element of the last cell in the list.\n\nIt will always evaluate to `NIL` with any proper list." trace "Enable tracing for the function bound to the symbol.\n\nWhen tracing is enabled for the function, before evaluating the call\nthe name and arguments will be printed to `*io-out*`." io-filename "Return the filename of the IO object." let* "Same as the first form of `let` but each of the binding\nexpressions may reference any of the varibles bound previously.\n\nIf a binding consists of a variable name alone, its value is\nset to `#<void>`." gensym? "Return `T` if the argument is a gensym, `NIL` otherwise." (doc
89group syntax) "StreetLISP syntax and macros." defdoc "Define documentation for a top level term.\n\nUseful in cases where the documentation for a term has to be set\nindependent of the definition of said term, or an additional form\nwith the same name has to be documented.\n\nIf `term` is a function signature and `doc` is not specified, just\nthe signature will be included in the documentation, without\nreplacing any previously defined.\n\nFirst `doc` argument is supposed to be a string with the description\nof the term. The following arguments are expected to be optional tag\npairings that provide grouping for multiple symbols (`:doc-group`),\n\"see also\" references (`:doc-see`) and code examples (`:doc-example`).\n\nCustom formatting lambda (`:doc-fmt`) may be used to process the\ndocumentation string when it's printed with `(help ...)`. It's used\nby `defstruct` to provide full constructor description in the output." cdddr "Shorthand for (cdr (cdr (cdr lst)))." copy-table "Return a new copy of the table with the keys and values preserved.\n\nNo copies of the keys nor values are created - original ones are\nreused." set-car! "Modify a cons cell (a list) in-place by putting `new-first` as its\nfirst element (head of the list). Return the modified cons\ncell (list)." receive "Capture multiple-return values into the given identifiers and\nevaluate the body." partition "Return two lists where the first contains the elements of the original\nlist which satisfy the predicate and the second containing the rest of\nthe elements.\n\nBoth lists will have the elements appear in the same order as in the\noriginal list." dotimes "Execute expressions in a loop the specified number of times.\n\nThe argument `var` defines the loop variable name, the iteration\ncount and (optionally) the resulting expression to evaluate and\nreturn the value of:\n\n (var-name count (result-expr #<void>))\n\nIf `result-expr` is not specified, `#<void>` is used instead.\n\nThe variable is incremented by `1` after each iteration, with its\ninitial value set to `0`, and may be referenced in expressions of\nthe `body`." has? "Return `T` if the table has a value associated with the key, `NIL` otherwise." vec "Construct a vector containing the specified arguments." while "Evaluate the body expressions until `cond` evaluates to `NIL`." rune "Construct a rune from a Unicode code point. Without code point\nspecified, an \"invalid\" rune is returned." *exit-hooks* "Internal variable, a list containing functions to call right before VM\nprocess exits." cadar "Shorthand for (car (cdr (car lst)))." type-error "Raise a type error exception." file "Open a file for I/O.\n\nAn `io` object is returned. Without any modes specified the file\nmust already exist and is opened in read-only mode.\n\nFiles are created with the default mode bits #o644." nth "Return nth element of the list, or `NIL` if the list is shorter." cdr "Return the second element of a cons cell (tail of a list) or `NIL` if\nnot available." / "Return the division of the arguments. With only one argument the\nresult of `1/x` is returned. If the result is integer-valued, it is\nreturned as an integer." newline "Write a single OS-specific line feed to the output.\n\nOn most systems it's a single character - `#\\linefeed` (`\\n`)." separate-doc-from-body "Take a list of terms and return a pair `(doc . body)`, where the first\nelement contains a list of documentation-related terms, and the second\ncontains the rest of the terms." cdadar "Shorthand for (cdr (car (cdr (car lst))))." foldr "Reduce the sequences to a single value by repeatedly applying the\nfunction right-associatively.\n\nThe function should be of the form `(fn e₀ e₁ … eₙ acc)`. For each\niteration each `eᵢ` will be set to successive values of the i'th\nsequence. The value `acc` will initially be set to `zero` and\nsubsequently to the previous value of the function application.\n\nThe iteration will terminate once the shortest sequence is exhausted.\n\nFor example, for two sequences (e₀ e₁ … eₙ) and (d₀ d₁ … dₙ), the\nresult will be:\n\n (fn e₀ d₀ (fn e₁ d₁ (…(fn eₙ dₙ zero)…)))\n\nNote that `foldr` is NOT tail call recursive." sqrt "Return the square root of `x`." reverse "Return the list with its elements in reverse order.\n\nThe original list is copied to construct the reversed version." lz-pack "Return data compressed using Lempel-Ziv.\n\nThe data must be an array, returned value will have the same type.\nThe optional `level` is between `0` and `10`. With `level` set to\n`0` a simple LZSS using hashing will be performed. Levels between\n`1` and `9` offer a trade-off between time/space and ratio. Level\n`10` is optimal but very slow." *prompt* "Function called by REPL to tell the user it's expecting input.\n\nThe default `*prompt*` function prints `#;> `, which by itself is a\ncommented-out expression, allowing the user to copy-paste the entire\nline (with the prompt) to re-evaluate." member "Return the tail of a list beginning with the item, or `NIL` otherwise.\nList elements are compared to the `item` using `equal?`." bignum? "Return `T` if the argument is a bignum, `NIL` otherwise." fixnum "Construct a fixnum." f64 "Construct a 64-bit floating point number." str->num "Return the number using the radix `base` in the string `s`.\n\nReturns `NIL` if the number could not be parsed. Any number of leading\nand/or trailing whitespace runes is allowed and those will be ignored." exp "Return the exponential - value of `e` (natural logarithms base) raised\nto the power of `p`." memq "Return the tail of a list beginning with the item, or `NIL` otherwise.\nList elements are compared to the `item` using `eq?`." (doc89group syntax) "StreetLISP syntax and macros." defdoc "Define documentation for a top level term.\n\nUseful in cases where the documentation for a term has to be set\nindependent of the definition of said term, or an additional form\nwith the same name has to be documented.\n\nIf `term` is a function signature and `doc` is not specified, just\nthe signature will be included in the documentation, without\nreplacing any previously defined.\n\nFirst `doc` argument is supposed to be a string with the description\nof the term. The following arguments are expected to be optional tag\npairings that provide grouping for multiple symbols (`:doc-group`),\n\"see also\" references (`:doc-see`) and code examples (`:doc-example`).\n\nCustom formatting lambda (`:doc-fmt`) may be used to process the\ndocumentation string when it's printed with `(help ...)`. It's used\nby `defstruct` to provide full constructor description in the output." cdddr "Shorthand for (cdr (cdr (cdr lst)))." copy-table "Return a new copy of the table with the keys and values preserved.\n\nNo copies of the keys nor values are created - original ones are\nreused." set-car! "Modify a cons cell (a list) in-place by putting `new-first` as its\nfirst element (head of the list). Return the modified cons\ncell (list)." receive "Capture multiple-return values into the given identifiers and\nevaluate the body." partition "Return two lists where the first contains the elements of the original\nlist which satisfy the predicate and the second containing the rest of\nthe elements.\n\nBoth lists will have the elements appear in the same order as in the\noriginal list." dotimes "Execute expressions in a loop the specified number of times.\n\nThe argument `var` defines the loop variable name, the iteration\ncount and (optionally) the resulting expression to evaluate and\nreturn the value of:\n\n (var-name count (result-expr #<void>))\n\nIf `result-expr` is not specified, `#<void>` is used instead.\n\nThe variable is incremented by `1` after each iteration, with its\ninitial value set to `0`, and may be referenced in expressions of\nthe `body`." has? "Return `T` if the table has a value associated with the key, `NIL` otherwise." vec "Construct a vector containing the specified arguments." while "Evaluate the body expressions until `cond` evaluates to `NIL`." rune "Construct a rune from a Unicode code point. Without code point\nspecified, an \"invalid\" rune is returned." *exit-hooks* "Internal variable, a list containing functions to call right before VM\nprocess exits." cadar "Shorthand for (car (cdr (car lst)))." type-error "Raise a type error exception." file "Open a file for I/O.\n\nAn `io` object is returned. Without any modes specified the file\nmust already exist and is opened in read-only mode.\n\nFiles are created with the default mode bits #o644." nth "Return nth element of the list, or `NIL` if the list is shorter." cdr "Return the second element of a cons cell (tail of a list) or `NIL` if\nnot available." / "Return the division of the arguments. With only one argument the\nresult of `1/x` is returned. If the result is integer-valued, it is\nreturned as an integer." newline "Write a single OS-specific line feed to the output.\n\nOn most systems it's a single character - `#\\linefeed` (`\\n`)." separate-doc-from-body "Take a list of terms and return a pair `(doc . body)`, where the first\nelement contains a list of documentation-related terms, and the second\ncontains the rest of the terms." cdadar "Shorthand for (cdr (car (cdr (car lst))))." foldr "Reduce the sequences to a single value by repeatedly applying the\nfunction right-associatively.\n\nThe function should be of the form `(fn e₀ e₁ … eₙ acc)`. For each\niteration each `eᵢ` will be set to successive values of the i'th\nsequence. The value `acc` will initially be set to `zero` and\nsubsequently to the previous value of the function application.\n\nThe iteration will terminate once the shortest sequence is exhausted.\n\nFor example, for two sequences (e₀ e₁ … eₙ) and (d₀ d₁ … dₙ), the\nresult will be:\n\n (fn e₀ d₀ (fn e₁ d₁ (…(fn eₙ dₙ zero)…)))\n\nNote that `foldr` is NOT tail call recursive." sqrt "Return the square root of `x`." reverse "Return the list with its elements in reverse order.\n\nThe original list is copied to construct the reversed version." lz-pack "Return data compressed using Lempel-Ziv.\n\nThe data must be an array, returned value will have the same type.\nThe optional `level` is between `0` and `10`. With `level` set to\n`0` a simple LZSS using hashing will be performed. Levels between\n`1` and `9` offer a trade-off between time/space and ratio. Level\n`10` is optimal but very slow." *prompt* "Function called by REPL to tell the user it's expecting input.\n\nThe default `*prompt*` function prints `#;> `, which by itself is a\ncommented-out expression, allowing the user to copy-paste the entire\nline (with the prompt) to re-evaluate." member "Return the tail of a list beginning with the item, or `NIL` otherwise.\nList elements are compared to the `item` using `equal?`." bignum? "Return `T` if the argument is a bignum, `NIL` otherwise." fixnum "Construct a fixnum." memq "Return the tail of a list beginning with the item, or `NIL` otherwise.\nList elements are compared to the `item` using `eq?`." f64 "Construct a 64-bit floating point number." str->num "Return the number using the radix `base` in the string `s`.\n\nReturns `NIL` if the number could not be parsed. Any number of leading\nand/or trailing whitespace runes is allowed and those will be ignored." exp "Return the exponential - value of `e` (natural logarithms base) raised\nto the power of `p`." (doc
90group debug) "Debugging utilities." +most-negative-fixnum+ "A constant integer closest to negative infinity that can be\nrepresented by fixnum type on this particular platform." caaaar "Shorthand for (car (car (car (car lst))))." io-column "Return the current column number of the IO object.\n\nColumn number is purely informative and is only being automatically\nupdated with the files opened for reading. If the cursor position is\nchanged via `io-skip` or `io-pos!`, the behavior is undefined." traced? "Return `T` if the tracing is enabled for the function, `NIL`\notherwise." cond "Select one of the clauses by evaluating the condition, evaluate the\naccompanied expressions for the matching clause and return the result.\n\nDifferent clause form variants are available. The most common is\n`(test then…)`, which gives the result of `then…` if `test` did not\nevaluate to `NIL`. Second form, `(test)`, which gives the result\nof `test` unless it's `NIL`. Third form, `(test => fn)`, calls `fn`\nwith a single argument which is the non-`NIL` result of evaluating\n`test`.\n\nThe special `else` clause condition, if specified, is used as a fallback\nif none of the other conditions were satisfied. If none were satisfied\n_and_ `else` was not provided, `NIL` is returned." (doc90group debug) "Debugging utilities." +most-negative-fixnum+ "A constant integer closest to negative infinity that can be\nrepresented by fixnum type on this particular platform." caaaar "Shorthand for (car (car (car (car lst))))." io-column "Return the current column number of the IO object.\n\nColumn number is purely informative and is only being automatically\nupdated with the files opened for reading. If the cursor position is\nchanged via `io-skip` or `io-pos!`, the behavior is undefined." traced? "Return `T` if the tracing is enabled for the function, `NIL`\notherwise." cond "Select one of the clauses by evaluating the condition, evaluate the\naccompanied expressions for the matching clause and return the result.\n\nDifferent clause form variants are available. The most common is\n`(test then…)`, which gives the result of `then…` if `test` did not\nevaluate to `NIL`. Second form, `(test)`, which gives the result\nof `test` unless it's `NIL`. Third form, `(test => fn)`, calls `fn`\nwith a single argument which is the non-`NIL` result of evaluating\n`test`.\n\nThe special `else` clause condition, if specified, is used as a fallback\nif none of the other conditions were satisfied. If none were satisfied\n_and_ `else` was not provided, `NIL` is returned." (doc
91group io) "Files and I/O functionality." s64 "Construct a 64-bit signed number." io-flush "Flush the contents of the output buffer to the underlying IO." assoc "Return a pair of a matching key and the associated value, or `NIL` if\nnone matched. Keys are compared using `equal?`." + "Return sum of the arguments or `0` when none specified." path-delete "Delete the name from the filesystem.\n\nThrows an IO error if the path does not exist or it failed to be\nremoved." cadadr "Shorthand for (car (cdr (car (cdr lst))))." foldr1 "Same as `foldr` but using the first element of the sequence as the\ninitial accumulator." compare "Return -1 if `x` is less than `y`, 0 if equal, and `1` if `y` is\ngreater than `x`." length "Return the length of the sequence.\n\nString's length is measured in UTF-8 codepoints. For tables the number\nof key-value pairs is returned.\n\nNote: for circular lists the result is `NIL`. A type error exception is\nthrown on improper lists, which are not considered valid sequences." *io-err* "Current (default) error output IO stream.\n\nFunctions may use `*io-err*` for error output, which then can be\nredirected to a different IO using `with-bindings`." print-exception "Print the exception in a human-readable form.\n\nExceptions are lists containing various information about the error.\nThey may optionally, as the first element, contain the error location\nof the form `(io row column)`." error "Raise an error." set-top-level-value! "Evaluate the expression and assign the result to the symbol in the top\nlevel (global) environment.\n\nThe use of this function is discouraged. For the usual assignment of\nvalues to names it is recommended instead to use `(def …)` and/or\n`(set! …)`." load "Read and evaluate expression from the file or IO object.\n\nIf the argument is an IO object it is _not_ closed after the load\nfinishes." getpid "Return the process ID of the StreetLISP VM within the operating system\nit's running on." keyword? "Return `T` if the argument is a keyword, `NIL` otherwise." aref "Return the sequence element specified by the subscripts. The sequence\ncan be an array, vector, a list. Multi-dimensional sequences\nof variating types are also supported." sym? "Return `T` if `v` is a symbol, `NIL` otherwise." defmacro "Define a new macro." u64 "Construct a 64-bit unsigned number." int-valued? "Return `T` if `x` is a number and is equal (as in `=`) to an\ninteger value of `x`." Instructions "VM instructions mapped to their encoded byte representation." assv "Return a pair of a matching key and the associated value, or `NIL` if\nnone matched. Keys are compared using `eqv?`." bignum "Construct a bignum. As opposed to a fixnum, its value is not limited." copy-vec "Return a copy of the vector with the same elements.\n\nNo copies of the values themselves are created, the original values\nare reused." eqv? "Return `T` if both `a` and `b` are of the same value and primitive\n(leaf) type, `NIL` otherwise. Neither cons cell nor vector are not\nconsidered primitive types as they may define deep structures." +f64-epsilon+ "A smallest positive floating point number such that\n`(+ 1.0 +f64-epsilon+)` is not equal to `1.0`." list "Return a list constructed of the arguments." __init_globals "Initialize globals that need to be set at load time." eof? "Return `T` if the argument is `#<eof>`, `NIL` otherwise.\n\nThis object is returned by I/O functions to signal end of file,\nwhere applicable." +pi+ "Mathematical constant π." revappend "Return list with its elements in reverse order, with `tail` appended\nto its end.\n\nThe original list is copied to construct the reversed version." quote "Leave the expression unevaluated." nreconc "Return list with its elements in reverse order, with `tail` appended\nto its end.\n\nThe original list may be modified by this function." defc*r "Define a shorthand for list access using `car` and `cdr`." (doc91group io) "Files and I/O functionality." s64 "Construct a 64-bit signed number." io-flush "Flush the contents of the output buffer to the underlying IO." assoc "Return a pair of a matching key and the associated value, or `NIL` if\nnone matched. Keys are compared using `equal?`." + "Return sum of the arguments or `0` when none specified." path-delete "Delete the name from the filesystem.\n\nThrows an IO error if the path does not exist or it failed to be\nremoved." cadadr "Shorthand for (car (cdr (car (cdr lst))))." foldr1 "Same as `foldr` but using the first element of the sequence as the\ninitial accumulator." compare "Return -1 if `x` is less than `y`, 0 if equal, and `1` if `y` is\ngreater than `x`." length "Return the length of the sequence.\n\nString's length is measured in UTF-8 codepoints. For tables the number\nof key-value pairs is returned.\n\nNote: for circular lists the result is `NIL`. A type error exception is\nthrown on improper lists, which are not considered valid sequences." *io-err* "Current (default) error output IO stream.\n\nFunctions may use `*io-err*` for error output, which then can be\nredirected to a different IO using `with-bindings`." print-exception "Print the exception in a human-readable form.\n\nExceptions are lists containing various information about the error.\nThey may optionally, as the first element, contain the error location\nof the form `(io row column)`." error "Raise an error." set-top-level-value! "Evaluate the expression and assign the result to the symbol in the top\nlevel (global) environment.\n\nThe use of this function is discouraged. For the usual assignment of\nvalues to names it is recommended instead to use `(def …)` and/or\n`(set! …)`." load "Read and evaluate expression from the file or IO object.\n\nIf the argument is an IO object it is _not_ closed after the load\nfinishes." getpid "Return the process ID of the StreetLISP VM within the operating system\nit's running on." keyword? "Return `T` if the argument is a keyword, `NIL` otherwise." aref "Return the sequence element specified by the subscripts. The sequence\ncan be an array, vector, a list. Multi-dimensional sequences\nof variating types are also supported." sym? "Return `T` if `v` is a symbol, `NIL` otherwise." defmacro "Define a new macro." u64 "Construct a 64-bit unsigned number." int-valued? "Return `T` if `x` is a number and is equal (as in `=`) to an\ninteger value of `x`." Instructions "VM instructions mapped to their encoded byte representation." assv "Return a pair of a matching key and the associated value, or `NIL` if\nnone matched. Keys are compared using `eqv?`." bignum "Construct a bignum. As opposed to a fixnum, its value is not limited." copy-vec "Return a copy of the vector with the same elements.\n\nNo copies of the values themselves are created, the original values\nare reused." eqv? "Return `T` if both `a` and `b` are of the same value and primitive\n(leaf) type, `NIL` otherwise. Neither cons cell nor vector are not\nconsidered primitive types as they may define deep structures." +f64-epsilon+ "A smallest positive floating point number such that\n`(+ 1.0 +f64-epsilon+)` is not equal to `1.0`." list "Return a list constructed of the arguments." __init_globals "Initialize globals that need to be set at load time." eof? "Return `T` if the argument is `#<eof>`, `NIL` otherwise.\n\nThis object is returned by I/O functions to signal end of file,\nwhere applicable." +pi+ "Mathematical constant π." revappend "Return list with its elements in reverse order, with `tail` appended\nto its end.\n\nThe original list is copied to construct the reversed version." quote "Leave the expression unevaluated." nreconc "Return list with its elements in reverse order, with `tail` appended\nto its end.\n\nThe original list may be modified by this function." defc*r "Define a shorthand for list access using `car` and `cdr`." (doc
92group misc) "Miscellaneous." read-all-of "Return the list containing the values returned by call `(fn io)` repeated\nuntil the IO object runs out of data." cddddr "Shorthand for (cdr (cdr (cdr (cdr lst))))." prog1 "Evaluate the expressions in order, return the result of the first\nexpression." logior "Return the result of bitwise OR (inclusive OR) operation on integers." cadr "Shorthand for `(car (cdr lst))`, that is, _first element of the\nsecond element_." cdadr "Shorthand for (cdr (car (cdr lst)))." (doc92group misc) "Miscellaneous." read-all-of "Return the list containing the values returned by call `(fn io)` repeated\nuntil the IO object runs out of data." cddddr "Shorthand for (cdr (cdr (cdr (cdr lst))))." prog1 "Evaluate the expressions in order, return the result of the first\nexpression." logior "Return the result of bitwise OR (inclusive OR) operation on integers." cadr "Shorthand for `(car (cdr lst))`, that is, _first element of the\nsecond element_." cdadr "Shorthand for (cdr (car (cdr lst)))." (doc
93group doc) "Writing and reading documentation." nan? "Return `T` if `v` is a floating point representation of NaN, either\nnegative or positive, `NIL` otherwise." caar "Shorthand for (car (car lst))." path-rename "Rename a file or a directory.\n\nThrows an IO error if the path does not exist or it failed to be\nrename. On most operating systems (not Plan 9), files can be moved\nbetween directories." div0 "Return the quotient of the truncated division `a/n`." set-syntax! "Associate a macro name with its application function." mod0 "Return the remainder of the truncated division `a/n`." last-pair "Return the last cell (pair) of the list." path-cwd "Return the full path to the current directory of the process, or\nchange it to the path specified with `to` argument." (doc93group doc) "Writing and reading documentation." nan? "Return `T` if `v` is a floating point representation of NaN, either\nnegative or positive, `NIL` otherwise." caar "Shorthand for (car (car lst))." path-rename "Rename a file or a directory.\n\nThrows an IO error if the path does not exist or it failed to be\nrename. On most operating systems (not Plan 9), files can be moved\nbetween directories." div0 "Return the quotient of the truncated division `a/n`." set-syntax! "Associate a macro name with its application function." mod0 "Return the remainder of the truncated division `a/n`." last-pair "Return the last cell (pair) of the list." path-cwd "Return the full path to the current directory of the process, or\nchange it to the path specified with `to` argument." (doc
94group compress) "Compression." *print-width* "Current maximal visible width (in terminal cells) of strings printed or `NIL`\nif strings are to be printed in full.\n\nTruncation does not occur in the middle of a codepoint or a grapheme cluster.\n\nNote: if a string contains an invalid rune or a control character for which\nits width is undefined, the string is printed in full if the rune in question\nwould fit otherwise." arr? "Return `T` if the argument is either a vector or an array, `NIL`\notherwise." cadaar "Shorthand for (car (cdr (car (car lst))))." unwind-protect "Evaluate `expr` first, then `finally`, regardless of whether\nevaluating the former resulted in any exception thrown or not.\n\nIf an exception has been thrown, it will be raised _after_ evaluating\n`finally`, else the result of `expr` is returned." cos "Return the cosine of `r`, where `r` is given in radians." io-skip "Update the current absolute position within the IO object by the\nrelative offset in bytes, return the resulting absolute position.\n\nTo specify the position relative to the end of the file, use the\noptional `:end T` argument with a negative offset." *io-in* "Current (default) input IO stream.\n\nFunctions may use `*io-in*` for input, which then can be redirected\nfrom a different IO using either `with-input-from` or (a more general)\n`with-bindings`." with-bindings "Evaluate expressions with the values of the specified variables\noverriden for the duration of the evaluation." every "Return `T` if the predicate is true for _every_ element of the list,\n`NIL` otherwise." atom? "Return `T` if `v` is a _not_ a cons cell, `NIL` otherwise. This is\nthe opposite of `cons?`.\n\nThe term \"atom\" comes from the idea of being indivisible." p64 "Construct a 64-bit abstract pointer value." str-utf8? "Return `T` if `s` is a valid UTF-8 string, `NIL` otherwise." apply "Return the result of applying a function `f` to a list of arguments.\n\nThe last argument must always be a list which gets spliced as\narguments to the function." cddr "Shorthand for (cdr (cdr lst))." not "Return `T` if `v` is `NIL`, `T` otherwise." print "Print the arguments to *io-out* with `*print-readably*` set to `T`.\n\nMultiple arguments are separated with a single `#\\space`." letrec "Same as the first form of `let` but each of the binding\nexpressions may reference any of the variables bound, before\nor after.\n\nIf a binding consists of a variable name alone, its value is\nset to `#<void>`." with-output "Evaluate expressions in `body` with `var` bound to `io` during the\nevaluation.\n\nIf expression `io` was not specified (first form), `var` will point\nto a new in-memory buffer and the resulting contents will be returned\nas a string.\n\nWith the second form the result of the last expression in the `body`\nwill be returned instead." cdar "Shorthand for (cdr (car lst))." cdaar "Shorthand for (cdr (car (car lst)))." iota "Return a list of generated indices.\n\nThe sequence of numbers generated will contain the elements:\n\n (start start+step … start+(count-1)*step)" caaddr "Shorthand for (car (car (cdr (cdr lst))))." environment "Return the list of all bound top level symbols." getprop "Return a property value associated with the symbol or `def` if\nmissing.\n\nIf the default value is not supplied and the property is missing,\nexception `key-error` will be thrown." (doc94group compress) "Compression." *print-width* "Current maximal visible width (in terminal cells) of strings printed or `NIL`\nif strings are to be printed in full.\n\nTruncation does not occur in the middle of a codepoint or a grapheme cluster.\n\nNote: if a string contains an invalid rune or a control character for which\nits width is undefined, the string is printed in full if the rune in question\nwould fit otherwise." arr? "Return `T` if the argument is either a vector or an array, `NIL`\notherwise." cadaar "Shorthand for (car (cdr (car (car lst))))." unwind-protect "Evaluate `expr` first, then `finally`, regardless of whether\nevaluating the former resulted in any exception thrown or not.\n\nIf an exception has been thrown, it will be raised _after_ evaluating\n`finally`, else the result of `expr` is returned." cos "Return the cosine of `r`, where `r` is given in radians." io-skip "Update the current absolute position within the IO object by the\nrelative offset in bytes, return the resulting absolute position.\n\nTo specify the position relative to the end of the file, use the\noptional `:end T` argument with a negative offset." *io-in* "Current (default) input IO stream.\n\nFunctions may use `*io-in*` for input, which then can be redirected\nfrom a different IO using either `with-input-from` or (a more general)\n`with-bindings`." with-bindings "Evaluate expressions with the values of the specified variables\noverriden for the duration of the evaluation." every "Return `T` if the predicate is true for _every_ element of the list,\n`NIL` otherwise." atom? "Return `T` if `v` is a _not_ a cons cell, `NIL` otherwise. This is\nthe opposite of `cons?`.\n\nThe term \"atom\" comes from the idea of being indivisible." p64 "Construct a 64-bit abstract pointer value." str-utf8? "Return `T` if `s` is a valid UTF-8 string, `NIL` otherwise." apply "Return the result of applying a function `f` to a list of arguments.\n\nThe last argument must always be a list which gets spliced as\narguments to the function." cddr "Shorthand for (cdr (cdr lst))." not "Return `T` if `v` is `NIL`, `T` otherwise." print "Print the arguments to *io-out* with `*print-readably*` set to `T`.\n\nMultiple arguments are separated with a single `#\\space`." letrec "Same as the first form of `let` but each of the binding\nexpressions may reference any of the variables bound, before\nor after.\n\nIf a binding consists of a variable name alone, its value is\nset to `#<void>`." with-output "Evaluate expressions in `body` with `var` bound to `io` during the\nevaluation.\n\nIf expression `io` was not specified (first form), `var` will point\nto a new in-memory buffer and the resulting contents will be returned\nas a string.\n\nWith the second form the result of the last expression in the `body`\nwill be returned instead." cdar "Shorthand for (cdr (car lst))." cdaar "Shorthand for (cdr (car (car lst)))." iota "Return a list of generated indices.\n\nThe sequence of numbers generated will contain the elements:\n\n (start start+step … start+(count-1)*step)" caaddr "Shorthand for (car (car (cdr (cdr lst))))." environment "Return the list of all bound top level symbols." getprop "Return a property value associated with the symbol or `def` if\nmissing.\n\nIf the default value is not supplied and the property is missing,\nexception `key-error` will be thrown." (doc
95group random) "Random numbers generation." * "Return product of the arguments or `1` when none specified." T "A boolean \"true\"." putprop "Associate a property with the symbol, return the value." *io-out* "Current (default) output IO stream.\n\nFunctions may use `*io-out*` for output, which then can be redirected\nto a different IO using either `with-output-to` or (a more general)\n`with-bindings`." repl "Run interactive prompt in a loop, reading and evaluating the\nexpressions entered by the user and printing the results.\n\nThis function is executed automatically if StreetLISP is started in\ninteractive mode." io-read-until "Return a string by reading from the IO object until encountering the\ndelimiting rune `r`. The returned string includes the delimiter." get "Return the value associated with the `key` in the table.\n\nIf the key isn't in the table then either return the optional\n`failed-result` argument or (if called without the argument) throw a\n`key-error` exception." table? "Return `T` if the argument is a table, `NIL` otherwise." u16 "Construct a 16-bit unsigned number." logxor "Return the result of bitwise XOR (exclusive OR) operation on integers." zip "Return a list where each nth element is a list of the corresponding\nelements from the parameter lists.\n\nThe resulting list is as long as the shortest of the arguments." str-width "Return the number of columns needed to represent a string or a rune.\n\nIf a non-printable control rune is encountered, the result is `NIL`,\nelse it is a non-negative integer. Rune `#\\null` is considered of width zero." acos "Return the arc cosine of `x` in radians." time->str "Return the number of nanoseconds since Epoch formatted as time and date.\n\nThis is the opposite of `str->time`." to-proper "Return a proper list that is a copy of the original list." caddr "Shorthand for (car (cdr (cdr lst)))." table-keys "Return the list of all keys of the table." set-doc! "Set the documentation for the symbol." catch "Evaluate `expr` and catch any exception thrown while evaluating by a\ncall to `throw` with the specified `tag`.\n\nIf no exception was thrown, return the result of the expression. In\ncase an exception thrown has a different tag, raise it further, to be\ncaught on a higher level of exception handling logic." __start "The system boot image entry.\n\nThis is the first function executed by the VM after initialization." NIL "An empty list. Can be used as the opposite of T in boolean\nexpressions." floor "Return the largest integer that is less than or equal to `x`.\n\nInfinity and NaN `floor` to themselves." add-exit-hook "Puts an one-argument function on top of the list of exit hooks.\n\nOn shutdown each exit hook is called with the exit status as a single\nargument, which is `NIL` on success or a string describing the error\notherwise.\n\nThe hook added last will be called first." str-join "Return concatenated elements of `strlist`, separated between each\nother with `sep`, as a single string.\n\nThe separator can be of any type suitable for `io-write` - a rune,\nstring, array of C primitives." (doc95group random) "Random numbers generation." T "A boolean \"true\"." * "Return product of the arguments or `1` when none specified." putprop "Associate a property with the symbol, return the value." *io-out* "Current (default) output IO stream.\n\nFunctions may use `*io-out*` for output, which then can be redirected\nto a different IO using either `with-output-to` or (a more general)\n`with-bindings`." repl "Run interactive prompt in a loop, reading and evaluating the\nexpressions entered by the user and printing the results.\n\nThis function is executed automatically if StreetLISP is started in\ninteractive mode." io-read-until "Return a string by reading from the IO object until encountering the\ndelimiting rune `r`. The returned string includes the delimiter." get "Return the value associated with the `key` in the table.\n\nIf the key isn't in the table then either return the optional\n`failed-result` argument or (if called without the argument) throw a\n`key-error` exception." table? "Return `T` if the argument is a table, `NIL` otherwise." u16 "Construct a 16-bit unsigned number." logxor "Return the result of bitwise XOR (exclusive OR) operation on integers." zip "Return a list where each nth element is a list of the corresponding\nelements from the parameter lists.\n\nThe resulting list is as long as the shortest of the arguments." str-width "Return the number of columns needed to represent a string or a rune.\n\nIf a non-printable control rune is encountered, the result is `NIL`,\nelse it is a non-negative integer. Rune `#\\null` is considered of width zero." acos "Return the arc cosine of `x` in radians." time->str "Return the number of nanoseconds since Epoch formatted as time and date.\n\nThis is the opposite of `str->time`." to-proper "Return a proper list that is a copy of the original list." caddr "Shorthand for (car (cdr (cdr lst)))." table-keys "Return the list of all keys of the table." set-doc! "Set the documentation for the symbol." catch "Evaluate `expr` and catch any exception thrown while evaluating by a\ncall to `throw` with the specified `tag`.\n\nIf no exception was thrown, return the result of the expression. In\ncase an exception thrown has a different tag, raise it further, to be\ncaught on a higher level of exception handling logic." __start "The system boot image entry.\n\nThis is the first function executed by the VM after initialization." NIL "An empty list. Can be used as the opposite of T in boolean\nexpressions." floor "Return the largest integer that is less than or equal to `x`.\n\nInfinity and NaN `floor` to themselves." add-exit-hook "Puts an one-argument function on top of the list of exit hooks.\n\nOn shutdown each exit hook is called with the exit status as a single\nargument, which is `NIL` on success or a string describing the error\notherwise.\n\nThe hook added last will be called first." str-join "Return concatenated elements of `strlist`, separated between each\nother with `sep`, as a single string.\n\nThe separator can be of any type suitable for `io-write` - a rune,\nstring, array of C primitives." (doc
96group sys) "OS-specific functions." >= "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 `v` is `#<void>`, `NIL` otherwise." +f32-epsilon+ "A smallest positive floating point number such that\n`(+ 1.0f +f32-epsilon+)` is not equal to `1.0f`." length= "Perform a bounded length test and return `T` if the length is `n`,\n`NIL` otherwise.\n\nUse this instead of `(= (length seq) n)`, since it avoids unnecessary\nwork and always terminates.\n\nThe value of `seq` can be of any sequence type." lognot "Return the result of bitwise NOT (complement) operation on an integer." int? "Return `T` if the argument is an integer, `NIL` otherwise." nanoseconds-monotonic "Return the number of nanoseconds passed since the first call to this\nfunction.\n\nThe first call will always return 0." io-discard-buffer "Discard the contents of the output buffer of the writable IO." with-input-from "Evaluate expressions in `body` with `*io-in*` set to `io` during the\nevaluation." *stdout* "Standard output IO stream." car "Return the first element of a cons cell (head of a list) or `NIL` if\nnot available." ceiling "Return the smallest integer that is greater than or equal to `x`.\n\nInfinity and NaN `ceiling` to themselves." arr "Construct a packed array containing the specified arguments.\n\nThe arguments will be coerced to a single `type` which must be\na fixed-width number or pointer type, or rune." length> "Perform a bounded length test and return `T` if the length is greater\nthan `n`, `NIL` otherwise.\n\nUse this instead of `(> (length seq) n)`, since it avoids unnecessary\nwork and always terminates.\n\nThe value of `seq` can be of any sequence type." <= "Return `T` if the arguments are in non-decreasing order (previous\none is less than or equal to the next one)." arg-error "Raise an argument error exception." (doc96group sys) "OS-specific functions." >= "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 `v` is `#<void>`, `NIL` otherwise." +f32-epsilon+ "A smallest positive floating point number such that\n`(+ 1.0f +f32-epsilon+)` is not equal to `1.0f`." length= "Perform a bounded length test and return `T` if the length is `n`,\n`NIL` otherwise.\n\nUse this instead of `(= (length seq) n)`, since it avoids unnecessary\nwork and always terminates.\n\nThe value of `seq` can be of any sequence type." lognot "Return the result of bitwise NOT (complement) operation on an integer." int? "Return `T` if the argument is an integer, `NIL` otherwise." nanoseconds-monotonic "Return the number of nanoseconds passed since the first call to this\nfunction.\n\nThe first call will always return 0." io-discard-buffer "Discard the contents of the output buffer of the writable IO." with-input-from "Evaluate expressions in `body` with `*io-in*` set to `io` during the\nevaluation." *stdout* "Standard output IO stream." car "Return the first element of a cons cell (head of a list) or `NIL` if\nnot available." arr "Construct a packed array containing the specified arguments.\n\nThe arguments will be coerced to a single `type` which must be\na fixed-width number or pointer type, or rune." ceiling "Return the smallest integer that is greater than or equal to `x`.\n\nInfinity and NaN `ceiling` to themselves." length> "Perform a bounded length test and return `T` if the length is greater\nthan `n`, `NIL` otherwise.\n\nUse this instead of `(> (length seq) n)`, since it avoids unnecessary\nwork and always terminates.\n\nThe value of `seq` can be of any sequence type." <= "Return `T` if the arguments are in non-decreasing order (previous\none is less than or equal to the next one)." arg-error "Raise an argument error exception." put! "Store the value associated with the key and return the table.\n\nAny existing value associated with the key will be replaced." (doc
97group number) "Operations on numbers, mathematical constants." asin "Return the arc sine of `x` in radians." log "Return the logarithm of `x` in `base`.\n\nDefault base is `e`, returning natural logarithm of the first\nargument." put! "Store the value associated with the key and return the table.\n\nAny existing value associated with the key will be replaced." cdaddr "Shorthand for (cdr (car (cdr (cdr lst))))." ash "Return the integer shifted by the specified number of bits to the\nright (negative `nbits`) or left (positive `nbits`)." str-sub "Return the portion of the string within the specified bounds.\n\nThe `start` and `end` index by rune. Specifying any index out of bounds\nof the string will result in an exception thrown.\n\nIf `end` isn't specified the portion is assumed to begin at `start`\nuntil the end of the original string." vec-alloc "Construct a vector of the specified `length` by repeating\nthe elements in `rest`." arr-alloc "Construct a packed array of the specified `length` by repeating\nthe elements in `rest`.\n\nThe arguments will be coerced to a single `type` which must be\na fixed-width number or pointer type, or rune." cddadr "Shorthand for (cdr (cdr (car (cdr lst))))." memv "Return the tail of a list beginning with the item, or `NIL` otherwise.\nList elements are compared to the `item` using `eqv?`." max "Return the largest among the arguments." closure? "Return `T` if the argument is a function that is implemented in LISP\n(as opposed to a C builtin), `NIL` otherwise." read-all "Return a list of terms read from the IO object until it ran out of\ndata." help-print-header "Format and print signature(s) of the term for `(help term)` output." arg-counts "VM instructions mapped to their expected arguments count." sleep "Halt the StreetLISP VM for the specified duration of time in seconds.b" s16 "Construct a 16-bit signed number." rune? "Return `T` if the value is a rune, `NIL` otherwise." os-setenv "Add or replace the value of the environment variable `name` to\n`value`.\n\nIf `value` is `NIL`, the variable is deleted from the environment if\nit exists." __script "Execute a single file at `path`.\n\nAn unhandled exception will result in it being printed to `*io-err*`\nand the process exiting with a non-zero (non-empty in case OS is Plan\n9) status signaling an error to its parent.") *doc-extra* #table(append ((:doc-example . "(append '(1) '(2 3) '(4))\n; ↳ (1 2 3 4)")97group number) "Operations on numbers, mathematical constants." log "Return the logarithm of `x` in `base`.\n\nDefault base is `e`, returning natural logarithm of the first\nargument." asin "Return the arc sine of `x` in radians." cdaddr "Shorthand for (cdr (car (cdr (cdr lst))))." ash "Return the integer shifted by the specified number of bits to the\nright (negative `nbits`) or left (positive `nbits`)." str-sub "Return the portion of the string within the specified bounds.\n\nThe `start` and `end` index by rune. Specifying any index out of bounds\nof the string will result in an exception thrown.\n\nIf `end` isn't specified the portion is assumed to begin at `start`\nuntil the end of the original string." vec-alloc "Construct a vector of the specified `length` by repeating\nthe elements in `rest`." arr-alloc "Construct a packed array of the specified `length` by repeating\nthe elements in `rest`.\n\nThe arguments will be coerced to a single `type` which must be\na fixed-width number or pointer type, or rune." cddadr "Shorthand for (cdr (cdr (car (cdr lst))))." memv "Return the tail of a list beginning with the item, or `NIL` otherwise.\nList elements are compared to the `item` using `eqv?`." max "Return the largest among the arguments." closure? "Return `T` if the argument is a function that is implemented in LISP\n(as opposed to a C builtin), `NIL` otherwise." read-all "Return a list of terms read from the IO object until it ran out of\ndata." help-print-header "Format and print signature(s) of the term for `(help term)` output." arg-counts "VM instructions mapped to their expected arguments count." sleep "Halt the StreetLISP VM for the specified duration of time in seconds.b" s16 "Construct a 16-bit signed number." rune? "Return `T` if the value is a rune, `NIL` otherwise." os-setenv "Add or replace the value of the environment variable `name` to\n`value`.\n\nIf `value` is `NIL`, the variable is deleted from the environment if\nit exists." __script "Execute a single file at `path`.\n\nAn unhandled exception will result in it being printed to `*io-err*`\nand the process exiting with a non-zero (non-empty in case OS is Plan\n9) status signaling an error to its parent.") *doc-extra* #table(append ((:doc-example . "(append '(1) '(2 3) '(4))\n; ↳ (1 2 3 4)")
98(:doc-example . "(append '(1))\n; ↳ (1)") (:doc-group . list) (:doc-see . nconc) (:doc-see . revappend)) io-eof? ((:doc-group . io)) path-exists? ((:doc-group . io)98(:doc-example . "(append '(1))\n; ↳ (1)") (:doc-group . list) (:doc-see . nconc) (:doc-see . revappend)) io-eof? ((:doc-group . io)) path-exists? ((:doc-group . io)
99(:doc-see . file) (:doc-see . path-delete)) cadddr ((:doc-group . list)) sort ((:doc-example . "; simple sort (note: symbols > numbers)\n(sort '(1a 1 0 2b e 3) <)\n; ↳ (0 1 3 1a 2b e)")99(:doc-see . file) (:doc-see . path-delete)) cadddr ((:doc-group . list)) sort ((:doc-example . "; simple sort (note: symbols > numbers)\n(sort '(1a 1 0 2b e 3) <)\n; ↳ (0 1 3 1a 2b e)")
100(:doc-example . "; sort in lexicographical order (as strings)\n(sort '(1a 1 0 2b e 3) < :key str)\n; ↳ (0 1 1a 2b 3 e)")100(:doc-example . "; sort in lexicographical order (as strings)\n(sort '(1a 1 0 2b e 3) < :key str)\n; ↳ (0 1 1a 2b 3 e)")
@@ -112,8 +112,8 @@ group number) "Operations on numbers, mathematical constants." asin "Return the · 11 unmodified lines
112(:doc-see . u32)) u8 ((:doc-group . number) (:doc-see . s8)) any ((:doc-example . "(any even? '(1 3 5 7)) ; any even number?\n; ↳ NIL")112(:doc-see . u32)) u8 ((:doc-group . number) (:doc-see . s8)) any ((:doc-example . "(any even? '(1 3 5 7)) ; any even number?\n; ↳ NIL")
113(:doc-example . "(any (λ (s) (length> s 1)) ; any string longer than one rune?\n '(\"ab\" \"cd\" \"e\"))\n; ↳ T")113(:doc-example . "(any (λ (s) (length> s 1)) ; any string longer than one rune?\n '(\"ab\" \"cd\" \"e\"))\n; ↳ T")
114(:doc-group . list) (:doc-see . every)) nthcdr ((:doc-example . "(def l '(a b c))\n(nthcdr l 1)\n; ↳ (b c)\n(nthcdr l 2)\n; ↳ (c)\n(nthcdr l 10)\n; ↳ NIL")114(:doc-group . list) (:doc-see . every)) nthcdr ((:doc-example . "(def l '(a b c))\n(nthcdr l 1)\n; ↳ (b c)\n(nthcdr l 2)\n; ↳ (c)\n(nthcdr l 10)\n; ↳ NIL")
115(:doc-group . list) (:doc-see . nth)) os-getenv ((:doc-group . sys) (:doc-see . os-setenv)) s8 ((:doc-group . number)115(:doc-group . list) (:doc-see . nth)) s8 ((:doc-group . number) (:doc-see . u8)) os-getenv ((:doc-group . sys)
116(:doc-see . u8)) tag-of ((:doc-example . "(tag-of 1)\n; ↳ fixnum") (:doc-example . "(tag-of NIL)\n; ↳ special")116(:doc-see . os-setenv)) tag-of ((:doc-example . "(tag-of 1)\n; ↳ fixnum") (:doc-example . "(tag-of NIL)\n; ↳ special")
117(:doc-example . "(tag-of \"hello\")\n; ↳ cvalue")117(:doc-example . "(tag-of \"hello\")\n; ↳ cvalue")
118(:doc-example . "(tag-of (s32 1))\n; ↳ unboxed")118(:doc-example . "(tag-of (s32 1))\n; ↳ unboxed")
119(:doc-group . vm) (:doc-see . type-of)) io-close ((:doc-example . "(def f (file \"/dev/random\"))\n(io-read f 'u8)\n; ↳ #u8(123)\n(io-close f)\n(io-read f 'u8)\n; ‼ I/O error: closed file")119(:doc-group . vm) (:doc-see . type-of)) io-close ((:doc-example . "(def f (file \"/dev/random\"))\n(io-read f 'u8)\n; ↳ #u8(123)\n(io-close f)\n(io-read f 'u8)\n; ‼ I/O error: closed file")
@@ -134,13 +134,12 @@ group number) "Operations on numbers, mathematical constants." asin "Return the · 14 unmodified lines
134(:doc-example . "(def a '(1))\n(def b '(1))\n(eq? a b)\n; ↳ NIL") (:doc-group . compare) (:doc-group . builtin)) *random-state* ((:doc-group . random)134(:doc-example . "(def a '(1))\n(def b '(1))\n(eq? a b)\n; ↳ NIL") (:doc-group . compare) (:doc-group . builtin)) *random-state* ((:doc-group . random)
135(:doc-see . make-random-state) (:doc-see . random-state?)) io->str ((:doc-group . io)) bound? ((:doc-example . "(bound? 'bound?)\n; ↳ T")135(:doc-see . make-random-state) (:doc-see . random-state?)) io->str ((:doc-group . io)) bound? ((:doc-example . "(bound? 'bound?)\n; ↳ T")
136(:doc-example . "(bound? 'doesnotcompute)\n; ↳ NIL") (:doc-group . builtin)) list->vec ((:doc-example . "(list->vec '(1 2 a))\n; ↳ #(1 2 a)")136(:doc-example . "(bound? 'doesnotcompute)\n; ↳ NIL") (:doc-group . builtin)) list->vec ((:doc-example . "(list->vec '(1 2 a))\n; ↳ #(1 2 a)")
137(:doc-group . list) (:doc-see . vec->list)) odd? ((:doc-group . number) (:doc-see . even?)) def ((:doc-example . "; a function with documentation (first form)\n(def (f x)\n «Return the square of doubled `x`.»\n :doc-example\n «(f 3)\n ; ↳ 36»\n :doc-group cool-funcs ; documentation group for (help groups)\n :doc-see g ; reference another function in the documentation\n (def (g y) ; an internal function\n (+ y y))\n (* (g x) (g x)))\n(f 2)\n; ↳ 16")137(:doc-group . list) (:doc-see . vec->list)) def ((:doc-example . "; a function with documentation (first form)\n(def (f x)\n «Return the square of doubled `x`.»\n :doc-example\n «(f 3)\n ; ↳ 36»\n :doc-group cool-funcs ; documentation group for (help groups)\n :doc-see g ; reference another function in the documentation\n (def (g y) ; an internal function\n (+ y y))\n (* (g x) (g x)))\n(f 2)\n; ↳ 16")
138(:doc-example . "; a variable (second form)\n(def x (length \"hello\"))\nx\n; ↳ 5") (:doc-group . syntax)138(:doc-example . "; a variable (second form)\n(def x (length \"hello\"))\nx\n; ↳ 5")
139(:doc-see . defdoc) (:doc-see . set!) (:doc-see . let)) call-with-values ((:doc-example . "(call-with-values (λ () (values 1 2 3))\n (λ (a b c) b))\n; ↳ 2")139(:doc-group . syntax) (:doc-see . defdoc) (:doc-see . set!)
140(:doc-see . let)) call-with-values ((:doc-example . "(call-with-values (λ () (values 1 2 3))\n (λ (a b c) b))\n; ↳ 2")
140(:doc-example . "(call-with-values (λ () (list 1 2 3))\n (λ (lst) (cadr lst)))\n; ↳ 2")141(:doc-example . "(call-with-values (λ () (list 1 2 3))\n (λ (lst) (cadr lst)))\n; ↳ 2")
141(:doc-group . syntax)142(:doc-group . syntax) (:doc-see . receive) (:doc-see . values)) odd? ((:doc-group . number) (:doc-see . even?)) list? ((:doc-group . list)
142(:doc-see . receive)
143(:doc-see . values)) list? ((:doc-group . list)
144(:doc-group . type) (:doc-see . list) (:doc-see . proper-list?)) str-rep ((:doc-example . "(str-rep \"oi\" 3)\n; ↳ \"oioioi\"")143(:doc-group . type) (:doc-see . list) (:doc-see . proper-list?)) str-rep ((:doc-example . "(str-rep \"oi\" 3)\n; ↳ \"oioioi\"")
145(:doc-example . "(str-rep #\\ы 5)\n; ↳ \"ыыыыы\"")144(:doc-example . "(str-rep #\\ы 5)\n; ↳ \"ыыыыы\"")
146(:doc-example . "(str-rep 'a 3)\n; ↳ \"aaa\"")145(:doc-example . "(str-rep 'a 3)\n; ↳ \"aaa\"")
@@ -170,24 +169,25 @@ group number) "Operations on numbers, mathematical constants." asin "Return the · 23 unmodified lines
170(:doc-example . "(proper-list? '(1)) ; a list with one element\n; ↳ T")169(:doc-example . "(proper-list? '(1)) ; a list with one element\n; ↳ T")
171(:doc-example . "(proper-list? '(1 . 2)) ; a pair, cdr of the cell is 2\n; ↳ NIL")170(:doc-example . "(proper-list? '(1 . 2)) ; a pair, cdr of the cell is 2\n; ↳ NIL")
172(:doc-example . "(proper-list? '#0=(1 . #0#)) ; on a circular list\n; ↳ NIL")171(:doc-example . "(proper-list? '#0=(1 . #0#)) ; on a circular list\n; ↳ NIL")
173(:doc-group . list) (:doc-group . type) (:doc-see . list?)) random ((:doc-example . "(random 1)\n; ↳ 1")172(:doc-group . list) (:doc-group . type) (:doc-see . list?)) io-filename! ((:doc-example . "(def f (buffer))\n(io-filename b)\n; ↳ \"\"\n(io-filename! b \"new name\") ; change the filename\n; ↳ \"new name\"\n(io-filename b)\n; ↳ \"new name\"")
174(:doc-example . "(random 10000000000000000000000000000000000)\n; ↳ 5312781302474765749507273681609477")173(:doc-group . io) (:doc-see . io-filename)) random ((:doc-example . "(random 1)\n; ↳ 1") (:doc-example . "(random 10000000000000000000000000000000000)\n; ↳ 5312781302474765749507273681609477")
175(:doc-example . "(random 1.0)\n; ↳ 0.69517") (:doc-group . random) (:doc-see . make-random-state)) io-filename! ((:doc-example . "(def f (buffer))\n(io-filename b)\n; ↳ \"\"\n(io-filename! b \"new name\") ; change the filename\n; ↳ \"new name\"\n(io-filename b)\n; ↳ \"new name\"")174(:doc-example . "(random 1.0)\n; ↳ 0.69517") (:doc-group . random) (:doc-see . make-random-state)) *directory-separator* ((:doc-group . sys)
176(:doc-group . io) (:doc-see . io-filename)) *directory-separator* ((:doc-group . sys) (:doc-see . *linefeed*)) reverse! ((:doc-example . "(def a '(1 2 3))\n(reverse! a)\n; ↳ (3 2 1)\na\n; ↳ (1) ; original list modified")175(:doc-see . *linefeed*)) reverse! ((:doc-example . "(def a '(1 2 3))\n(reverse! a)\n; ↳ (3 2 1)\na\n; ↳ (1) ; original list modified")
177(:doc-group . list) (:doc-see . reverse)) eval ((:doc-example . "(eval '(begin (set! x 1 y 2) (+ x y)))\n; ↳ 3\nx\n; ↳ 1\ny\n; ↳ 2")176(:doc-group . list) (:doc-see . reverse)) eval ((:doc-example . "(eval '(begin (set! x 1 y 2) (+ x y)))\n; ↳ 3\nx\n; ↳ 1\ny\n; ↳ 2")
178(:doc-group . vm) (:doc-see . load)) cdaadr ((:doc-group . list)) u32 ((:doc-group . number)177(:doc-group . vm)
178(:doc-see . load)) cdaadr ((:doc-group . list)) u32 ((:doc-group . number)
179(:doc-see . s32)) cons ((:doc-example . "(cons 1 2)\n; ↳ (1 . 2)")179(:doc-see . s32)) cons ((:doc-example . "(cons 1 2)\n; ↳ (1 . 2)")
180(:doc-example . "(cons 1 '(2))\n; ↳ (1 2)")180(:doc-example . "(cons 1 '(2))\n; ↳ (1 2)")
181(:doc-example . "(cons 1 (cons 2 (cons 3 NIL)))\n; ↳ (1 2 3)") (:doc-group . list)181(:doc-example . "(cons 1 (cons 2 (cons 3 NIL)))\n; ↳ (1 2 3)") (:doc-group . list)
182(:doc-see . cons?) (:doc-see . list) (:doc-group . builtin)) filter ((:doc-example . "(filter odd? '(0 1 2 3 4))\n; ↳ (1 3)")182(:doc-see . cons?) (:doc-see . list) (:doc-group . builtin)) filter ((:doc-example . "(filter odd? '(0 1 2 3 4))\n; ↳ (1 3)")
183(:doc-group . list) (:doc-see . partition)) do ((:doc-example . "(do ((x 0 (+ x 1))) ; x=0 at first, x=x+1 after each step\n ((> (sin x) 0.95) ; loop until sin(x) > 0.95\n (newline) ; print a linefeed when loop terminates\n x) ; return final value of x\n (princ x)) ; print x on each step\n; ‼ 01234567\n; ↳ 8")183(:doc-group . list) (:doc-see . partition)) do ((:doc-example . "(do ((x 0 (+ x 1))) ; x=0 at first, x=x+1 after each step\n ((> (sin x) 0.95) ; loop until sin(x) > 0.95\n (newline) ; print a linefeed when loop terminates\n x) ; return final value of x\n (princ x)) ; print x on each step\n; ‼ 01234567\n; ↳ 8")
184(:doc-group . syntax) (:doc-see . for) (:doc-see . while)) make-random-state ((:doc-group . random)184(:doc-group . syntax) (:doc-see . for) (:doc-see . while)) assq ((:doc-group . list)
185(:doc-see . *random-state*) (:doc-see . random-state?) (:doc-see . random)) assq ((:doc-group . list)185(:doc-see . assoc) (:doc-see . assv)) io-buffer-mode! ((:doc-group . io) (:doc-see . io-buffer-mode)) let ((:doc-example . "(let ((a 123) (b 456) c) ; first form\n (cons (+ a b) (void? c)))\n; ↳ (579 . T)")
186(:doc-see . assoc)
187(:doc-see . assv)) let ((:doc-example . "(let ((a 123) (b 456) c) ; first form\n (cons (+ a b) (void? c)))\n; ↳ (579 . T)")
188(:doc-example . "(let loop ((a (iota 3 1))) ; second form\n (when a\n (princ (car a))\n (loop (cdr a))))\n; ‼ 123\n; ↳ NIL")186(:doc-example . "(let loop ((a (iota 3 1))) ; second form\n (when a\n (princ (car a))\n (loop (cdr a))))\n; ‼ 123\n; ↳ NIL")
189(:doc-group . syntax) (:doc-see . let*) (:doc-see . letrec)) io-buffer-mode! ((:doc-group . io)187(:doc-group . syntax) (:doc-see . let*) (:doc-see . letrec)) make-random-state ((:doc-group . random)
190(:doc-see . io-buffer-mode)) del! ((:doc-example . "(def t #table(a 1 b 2))\n(del! t 'c)\n; ↳ #table(b 2 a 1)\n(del! t 'b)\n; ↳ #table(a 1)\nt\n; ↳ #table(a 1)")188(:doc-see . *random-state*)
189(:doc-see . random-state?)
190(:doc-see . random)) del! ((:doc-example . "(def t #table(a 1 b 2))\n(del! t 'c)\n; ↳ #table(b 2 a 1)\n(del! t 'b)\n; ↳ #table(a 1)\nt\n; ↳ #table(a 1)")
191(:doc-group . table) (:doc-see . has?) (:doc-see . get) (:doc-see . put!)) when ((:doc-example . "(when (eq? cmd 'exit)\n(princ \"exiting!\")\n(newline)\n(exit))")191(:doc-group . table) (:doc-see . has?) (:doc-see . get) (:doc-see . put!)) when ((:doc-example . "(when (eq? cmd 'exit)\n(princ \"exiting!\")\n(newline)\n(exit))")
192(:doc-group . syntax)192(:doc-group . syntax)
193(:doc-see . unless)193(:doc-see . unless)
@@ -280,7 +280,8 @@ group number) "Operations on numbers, mathematical constants." asin "Return the · 86 unmodified lines
280(:doc-group . vm)) ptr ((:doc-group . number) (:doc-see . p32) (:doc-see . p64) (:doc-see . ptr?)) caddar ((:doc-group . list)) print-stack-trace ((:doc-group . error)280(:doc-group . vm)) ptr ((:doc-group . number) (:doc-see . p32) (:doc-see . p64) (:doc-see . ptr?)) caddar ((:doc-group . list)) print-stack-trace ((:doc-group . error)
281(:doc-see . stacktrace)) *stdin* ((:doc-group . io) (:doc-see . *stdout*) (:doc-see . *stderr*)) cosh ((:doc-group . number)) values ((:doc-group . syntax)281(:doc-see . stacktrace)) *stdin* ((:doc-group . io) (:doc-see . *stdout*) (:doc-see . *stderr*)) cosh ((:doc-group . number)) values ((:doc-group . syntax)
282(:doc-see . call-with-values) (:doc-see . receive)) < ((:doc-group . compare) (:doc-group . builtin)) copy-tree ((:doc-example . "(def a '(1 (2 3)))\n(def b (copy-tree a))\n(equal? a b)\n; ↳ T\n(eq? a b)\n; ↳ NIL\n(equal? (cadr a) (cadr b))\n; ↳ T\n(eq? (cadr a) (cadr b))\n; ↳ NIL")282(:doc-see . call-with-values) (:doc-see . receive)) < ((:doc-group . compare) (:doc-group . builtin)) copy-tree ((:doc-example . "(def a '(1 (2 3)))\n(def b (copy-tree a))\n(equal? a b)\n; ↳ T\n(eq? a b)\n; ↳ NIL\n(equal? (cadr a) (cadr b))\n; ↳ T\n(eq? (cadr a) (cadr b))\n; ↳ NIL")
283(:doc-group . list) (:doc-see . copy-list)) f32 ((:doc-group . number) (:doc-see . f64)) sin ((:doc-group . number)) io-copy ((:doc-group . io)283(:doc-group . list) (:doc-see . copy-list)) sin ((:doc-group . number)) f32 ((:doc-group . number)
284(:doc-see . f64)) io-copy ((:doc-group . io)
284(:doc-see . io-copy-until)) > ((:doc-group . compare)) str-rune ((:doc-example . "(str-rune \"йцукен\" 3)\n; ↳ #\\к")285(:doc-see . io-copy-until)) > ((:doc-group . compare)) str-rune ((:doc-example . "(str-rune \"йцукен\" 3)\n; ↳ #\\к")
285(:doc-group . string) (:doc-see . str-sub)) foldl ((:doc-example . "(foldl cons NIL (iota 5))\n; ↳ (4 3 2 1 0)")286(:doc-group . string) (:doc-see . str-sub)) foldl ((:doc-example . "(foldl cons NIL (iota 5))\n; ↳ (4 3 2 1 0)")
286(:doc-example . "(foldl + 0 (iota 5))\n; ↳ 10") (:doc-example . "(foldl (λ (x y a) (+ (* x y) a)) 0 (iota 5) (iota 5))\n; ↳ 30")287(:doc-example . "(foldl + 0 (iota 5))\n; ↳ 10") (:doc-example . "(foldl (λ (x y a) (+ (* x y) a)) 0 (iota 5) (iota 5))\n; ↳ 30")
@@ -293,20 +294,19 @@ group number) "Operations on numbers, mathematical constants." asin "Return the · 6 unmodified lines
293(:doc-see . *directory-separator*)) str? ((:doc-group . type)294(:doc-see . *directory-separator*)) str? ((:doc-group . type)
294(:doc-see . str) (:doc-see . str-utf8?)) cons? ((:doc-example . "(cons? 0)\n; ↳ NIL") (:doc-example . "(cons? NIL)\n; ↳ NIL")295(:doc-see . str) (:doc-see . str-utf8?)) cons? ((:doc-example . "(cons? 0)\n; ↳ NIL") (:doc-example . "(cons? NIL)\n; ↳ NIL")
295(:doc-example . "(cons? '(1))\n; ↳ T") (:doc-group . type) (:doc-see . cons) (:doc-see . list?)296(:doc-example . "(cons? '(1))\n; ↳ T") (:doc-group . type) (:doc-see . cons) (:doc-see . list?)
296(:doc-group . builtin)) str-split ((:doc-example . "(str-split \"hello world\")\n; ↳ (\"hello\" \"world\")")297(:doc-group . builtin)) io-read ((:doc-example . "(io-read f 'utf8 5)\n; ↳ \"hello\"")
297(:doc-example . "(str-split \"multiple spaces \")\n; ↳ (\"multiple\" \"\" \"\" \"spaces\" \"\")")
298(:doc-example . "(str-split \"multiple spaces \" :trim T)\n; ↳ (\"multiple\" \"spaces\")")
299(:doc-example . "(str-split \"too many vowels\" \"aeiou\")\n; ↳ (\"t\" \"\" \" m\" \"ny v\" \"w\" \"ls\")")
300(:doc-group . string)) io-read ((:doc-example . "(io-read f 'utf8 5)\n; ↳ \"hello\"")
301(:doc-example . "(io-read f 'u32)\n; ↳ 57")298(:doc-example . "(io-read f 'u32)\n; ↳ 57")
302(:doc-example . "(io-read f 'u32 3)\n; ↳ #arr(u32 0 1 2)")299(:doc-example . "(io-read f 'u32 3)\n; ↳ #arr(u32 0 1 2)")
303(:doc-example . "(io-read f 'rune 6)\n; ↳ #arr(rune #\\λ #\\a #\\m #\\b #\\d #\\a)")300(:doc-example . "(io-read f 'rune 6)\n; ↳ #arr(rune #\\λ #\\a #\\m #\\b #\\d #\\a)")
304(:doc-group . io) (:doc-see . io-write)301(:doc-group . io) (:doc-see . io-write) (:doc-see . io-read-until)) str-split ((:doc-example . "(str-split \"hello world\")\n; ↳ (\"hello\" \"world\")")
305(:doc-see . io-read-until)) truncate ((:doc-example . "(truncate -123.45)\n; ↳ -123")302(:doc-example . "(str-split \"multiple spaces \")\n; ↳ (\"multiple\" \"\" \"\" \"spaces\" \"\")")
303(:doc-example . "(str-split \"multiple spaces \" :trim T)\n; ↳ (\"multiple\" \"spaces\")")
304(:doc-example . "(str-split \"too many vowels\" \"aeiou\")\n; ↳ (\"t\" \"\" \" m\" \"ny v\" \"w\" \"ls\")")
305(:doc-group . string)) truncate ((:doc-example . "(truncate -123.45)\n; ↳ -123")
306(:doc-example . "(truncate 299.9)\n; ↳ 299") (:doc-group . number)) aset! ((:doc-example . "(def a '((1 #(2 (3)) 4)))\n(aset! a 1 'x)\n; ‼ index 1 out of bounds\n(aset! a 0 0 'x)\n; ↳ x\na\n; ↳ ((x #(2 (3)) 4))\n(aset! a 0 1 9)\n; ↳ 9\na\n; ↳ ((x #(9 (3)) 4))")306(:doc-example . "(truncate 299.9)\n; ↳ 299") (:doc-group . number)) aset! ((:doc-example . "(def a '((1 #(2 (3)) 4)))\n(aset! a 1 'x)\n; ‼ index 1 out of bounds\n(aset! a 0 0 'x)\n; ↳ x\na\n; ↳ ((x #(2 (3)) 4))\n(aset! a 0 1 9)\n; ↳ 9\na\n; ↳ ((x #(9 (3)) 4))")
307(:doc-group . array)307(:doc-group . array) (:doc-see . aref) (:doc-group . builtin)) - ((:doc-example . "(- 1.5)\n; ↳ -1.5")
308(:doc-see . aref) (:doc-group . builtin)) - ((:doc-example . "(- 1.5)\n; ↳ -1.5")308(:doc-example . "(- 3 2)\n; ↳ 1")
309(:doc-example . "(- 3 2)\n; ↳ 1") (:doc-group . number) (:doc-group . builtin)) io-truncate ((:doc-group . io)) makunbound ((:doc-example . "(def x 1)\n(bound? 'x)\n; ↳ T\nx\n; ↳ 1\n(makunbound 'x)\n(bound? 'x)\n; ↳ NIL\nx\n; ‼ eval: variable x has no value")309(:doc-group . number) (:doc-group . builtin)) io-truncate ((:doc-group . io)) makunbound ((:doc-example . "(def x 1)\n(bound? 'x)\n; ↳ T\nx\n; ↳ 1\n(makunbound 'x)\n(bound? 'x)\n; ↳ NIL\nx\n; ‼ eval: variable x has no value")
310(:doc-group . misc) (:doc-see . bound?)) quasiquote ((:doc-example . "`(0 1 (+ 2 3))\n; ↳ (0 1 (+ 2 3))")310(:doc-group . misc) (:doc-see . bound?)) quasiquote ((:doc-example . "`(0 1 (+ 2 3))\n; ↳ (0 1 (+ 2 3))")
311(:doc-group . syntax) (:doc-see . quote) (:doc-see . unquote)) io-column! ((:doc-group . io)311(:doc-group . syntax) (:doc-see . quote) (:doc-see . unquote)) io-column! ((:doc-group . io)
312(:doc-see . io-column) (:doc-see . io-line!)) copy-list ((:doc-example . "(def a '(1 2 3 4))\n(def b (copy-list a))\nb\n; ↳ (1 2 3 4)\n(eq? a b)\n; ↳ NIL\n(equal? a b)\n; ↳ T\n(copy-list a 3)\n; ↳ (1 2 3)\n(copy-list a 10)\n; ↳ (1 2 3 4)")312(:doc-see . io-column) (:doc-see . io-line!)) copy-list ((:doc-example . "(def a '(1 2 3 4))\n(def b (copy-list a))\nb\n; ↳ (1 2 3 4)\n(eq? a b)\n; ↳ NIL\n(equal? a b)\n; ↳ T\n(copy-list a 3)\n; ↳ (1 2 3)\n(copy-list a 10)\n; ↳ (1 2 3 4)")
@@ -384,13 +384,13 @@ group number) "Operations on numbers, mathematical constants." asin "Return the · 71 unmodified lines
384(:doc-see . memq) (:doc-see . memv)) bignum? ((:doc-group . type)384(:doc-see . memq) (:doc-see . memv)) bignum? ((:doc-group . type)
385(:doc-group . number)385(:doc-group . number)
386(:doc-see . bignum)) fixnum ((:doc-group . number)386(:doc-see . bignum)) fixnum ((:doc-group . number)
387(:doc-see . fixnum?)) f64 ((:doc-group . number) (:doc-see . f32)) str->num ((:doc-example . "(str->num \"1.2\")\n; ↳ 1.2")387(:doc-see . fixnum?)) memq ((:doc-group . list) (:doc-see . member) (:doc-see . memv)) f64 ((:doc-group . number)
388(:doc-see . f32)) str->num ((:doc-example . "(str->num \"1.2\")\n; ↳ 1.2")
388(:doc-example . "(str->num \"#x123\")\n; ↳ 291")389(:doc-example . "(str->num \"#x123\")\n; ↳ 291")
389(:doc-example . "(str->num \"ffff\" :base 16)\n; ↳ 65535")390(:doc-example . "(str->num \"ffff\" :base 16)\n; ↳ 65535")
390(:doc-example . "(str->num \"777\" :base 8)\n; ↳ 511")391(:doc-example . "(str->num \"777\" :base 8)\n; ↳ 511") (:doc-group . string)
391(:doc-group . string)
392(:doc-see . num->str)) exp ((:doc-example . "(exp 1)\n; ↳ 2.71828… ; e")392(:doc-see . num->str)) exp ((:doc-example . "(exp 1)\n; ↳ 2.71828… ; e")
393(:doc-group . number)) memq ((:doc-group . list) (:doc-see . member) (:doc-see . memv)) +most-negative-fixnum+ ((:doc-group . number)393(:doc-group . number)) +most-negative-fixnum+ ((:doc-group . number)
394(:doc-see . +most-positive-fixnum+)) caaaar ((:doc-group . list)) io-column ((:doc-group . io)394(:doc-see . +most-positive-fixnum+)) caaaar ((:doc-group . list)) io-column ((:doc-group . io)
395(:doc-see . io-line)395(:doc-see . io-line)
396(:doc-see . io-column!)) traced? ((:doc-example . "(traced? map)\n; ↳ NIL\n(trace 'map)\n(traced? map)\n; ↳ T\n(untrace 'map)\n(traced? map)\n; ↳ NIL")396(:doc-see . io-column!)) traced? ((:doc-example . "(traced? map)\n; ↳ NIL\n(trace 'map)\n(traced? map)\n; ↳ T\n(untrace 'map)\n(traced? map)\n; ↳ NIL")
@@ -477,16 +477,16 @@ group number) "Operations on numbers, mathematical constants." asin "Return the · 80 unmodified lines
477(:doc-group . io) (:doc-see . princ)) letrec ((:doc-example . "(letrec ((a (λ () 1))\n (b (λ () (+ (c) 1)))\n (c (λ () (+ (a) 1)))\n d)\n (list (a) (b) (c) (void? d)))\n; ↳ (1 3 2 T)")477(:doc-group . io) (:doc-see . princ)) letrec ((:doc-example . "(letrec ((a (λ () 1))\n (b (λ () (+ (c) 1)))\n (c (λ () (+ (a) 1)))\n d)\n (list (a) (b) (c) (void? d)))\n; ↳ (1 3 2 T)")
478(:doc-group . syntax) (:doc-see . let) (:doc-see . let*)) with-output ((:doc-example . "(with-output (s) (write \"hello\" s))\n; ↳ \"\\\"hello\\\"\"")478(:doc-group . syntax) (:doc-see . let) (:doc-see . let*)) with-output ((:doc-example . "(with-output (s) (write \"hello\" s))\n; ↳ \"\\\"hello\\\"\"")
479(:doc-example . "(def b (buffer))\n(with-output (s b) (io-write s \"hello\"))\n; ↳ 5\n(length b)\n; ↳ 5")479(:doc-example . "(def b (buffer))\n(with-output (s b) (io-write s \"hello\"))\n; ↳ 5\n(length b)\n; ↳ 5")
480(:doc-group . io) (:doc-see . with-output-to)) cdar ((:doc-group . list)) cdaar ((:doc-group . list)) iota ((:doc-example . "(iota 4)\n; ↳ (0 1 2 3)")480(:doc-group . io) (:doc-see . with-output-to)) cdaar ((:doc-group . list)) cdar ((:doc-group . list)) iota ((:doc-example . "(iota 4)\n; ↳ (0 1 2 3)")
481(:doc-example . "(iota 4 6)\n; ↳ (6 7 8 9)") (:doc-example . "(iota 4 6 -0.5)\n; ↳ (6 5.5 5.0 4.5)")481(:doc-example . "(iota 4 6)\n; ↳ (6 7 8 9)") (:doc-example . "(iota 4 6 -0.5)\n; ↳ (6 5.5 5.0 4.5)")
482(:doc-group . list) (:doc-see . map-int)) caaddr ((:doc-group . list)) environment ((:doc-group . debug)482(:doc-group . list) (:doc-see . map-int)) caaddr ((:doc-group . list)) environment ((:doc-group . debug)
483(:doc-group . vm)483(:doc-group . vm)
484(:doc-see . print-stack-trace)) getprop ((:doc-example . "(def x '(1 2 3))\n(putprop x 'words \"one two three\")\n; ↳ \"one two three\"\n(getprop x 'words)\n; ↳ \"one two three\"\n(getprop x 'huh)\n; ‼ key not found: huh\n(getprop x 'huh \"fallback\")\n; ↳ \"fallback\"")484(:doc-see . print-stack-trace)) getprop ((:doc-example . "(def x '(1 2 3))\n(putprop x 'words \"one two three\")\n; ↳ \"one two three\"\n(getprop x 'words)\n; ↳ \"one two three\"\n(getprop x 'huh)\n; ‼ key not found: huh\n(getprop x 'huh \"fallback\")\n; ↳ \"fallback\"")
485(:doc-group . prop) (:doc-see . putprop) (:doc-see . remprop)) putprop ((:doc-example . "(def x '(1 2 3))\n(putprop x 'words \"one two three\")\n; ↳ \"one two three\"\n(getprop x 'words)\n; ↳ \"one two three\"")485(:doc-group . prop) (:doc-see . putprop) (:doc-see . remprop)) putprop ((:doc-example . "(def x '(1 2 3))\n(putprop x 'words \"one two three\")\n; ↳ \"one two three\"\n(getprop x 'words)\n; ↳ \"one two three\"")
486(:doc-group . prop) (:doc-see . getprop)486(:doc-group . prop) (:doc-see . getprop)
487(:doc-see . remprop)) * ((:doc-group . number)487(:doc-see . remprop)) T ((:doc-example . "(not T)\n; ↳ NIL")
488(:doc-group . builtin)) T ((:doc-example . "(not T)\n; ↳ NIL") (:doc-example . "(if T 'yes 'no)\n; ↳ yes")488(:doc-example . "(if T 'yes 'no)\n; ↳ yes") (:doc-group . misc) (:doc-see)) * ((:doc-group . number)
489(:doc-see)) *io-out* ((:doc-group . io)489(:doc-group . builtin)) *io-out* ((:doc-group . io)
490(:doc-see . *io-err*) (:doc-see . *io-in*) (:doc-see . with-output-to)) repl ((:doc-group . vm)490(:doc-see . *io-err*) (:doc-see . *io-in*) (:doc-see . with-output-to)) repl ((:doc-group . vm)
491(:doc-see . that)491(:doc-see . that)
492(:doc-see . *interactive*)492(:doc-see . *interactive*)
@@ -510,9 +510,10 @@ group number) "Operations on numbers, mathematical constants." asin "Return the · 17 unmodified lines
510(:doc-group . error) (:doc-see . trycatch) (:doc-see . unwind-protect)) __start ((:doc-group . vm)510(:doc-group . error) (:doc-see . trycatch) (:doc-see . unwind-protect)) __start ((:doc-group . vm)
511(:doc-see . __finish)) NIL ((:doc-example . "(not NIL)\n; ↳ T")511(:doc-see . __finish)) NIL ((:doc-example . "(not NIL)\n; ↳ T")
512(:doc-example . "(if NIL 'yes 'no)\n; ↳ no") (:doc-example . "(car NIL)\n; ↳ NIL") (:doc-example . "(cdr NIL)\n; ↳ NIL")512(:doc-example . "(if NIL 'yes 'no)\n; ↳ no") (:doc-example . "(car NIL)\n; ↳ NIL") (:doc-example . "(cdr NIL)\n; ↳ NIL")
513(:doc-see . T)) floor ((:doc-example . "(floor 1.2)\n; ↳ 1.0") (:doc-example . "(floor -1.2)\n; ↳ -2.0")513(:doc-group . list) (:doc-see . T)) floor ((:doc-example . "(floor 1.2)\n; ↳ 1.0") (:doc-example . "(floor -1.2)\n; ↳ -2.0")
514(:doc-example . "(floor -5)\n; ↳ -5.0")514(:doc-example . "(floor -5)\n; ↳ -5.0")
515(:doc-group . number) (:doc-see . ceiling)) add-exit-hook ((:doc-group . vm)515(:doc-group . number)
516(:doc-see . ceiling)) add-exit-hook ((:doc-group . vm)
516(:doc-see . *exit-hooks*)) str-join ((:doc-example . "(str-join '(\"\" \"n\" \"9\" \"heh\")\n *directory-separator*)\n; ↳ \"/n/9/heh\"")517(:doc-see . *exit-hooks*)) str-join ((:doc-example . "(str-join '(\"\" \"n\" \"9\" \"heh\")\n *directory-separator*)\n; ↳ \"/n/9/heh\"")
517(:doc-example . "(str-join '(\"a\" \"b\" \"c\") #\\.)\n; ↳ \"a.b.c\"")518(:doc-example . "(str-join '(\"a\" \"b\" \"c\") #\\.)\n; ↳ \"a.b.c\"")
518(:doc-group . string) (:doc-see . str-split)) >= ((:doc-group . compare)) +f32-epsilon+ ((:doc-group . number)519(:doc-group . string) (:doc-see . str-split)) >= ((:doc-group . compare)) +f32-epsilon+ ((:doc-group . number)
@@ -544,9 +545,11 @@ group number) "Operations on numbers, mathematical constants." asin "Return the · 25 unmodified lines
544(:doc-example . "(vec-alloc 10 1 2.5 \"a\" 'b)\n; ↳ #(1 2.5 \"a\" b 1 2.5 \"a\" b 1 2.5)") (:doc-group . array)545(:doc-example . "(vec-alloc 10 1 2.5 \"a\" 'b)\n; ↳ #(1 2.5 \"a\" b 1 2.5 \"a\" b 1 2.5)") (:doc-group . array)
545(:doc-see . vec) (:doc-see . arr-alloc)) arr-alloc ((:doc-example . "(arr-alloc 'u16 5 -1)\n; ↳ #arr(u16 65535 65535 65535 65535 65535)")546(:doc-see . vec) (:doc-see . arr-alloc)) arr-alloc ((:doc-example . "(arr-alloc 'u16 5 -1)\n; ↳ #arr(u16 65535 65535 65535 65535 65535)")
546(:doc-example . "(arr-alloc 's8 10 0 1 2)\n; ↳ #arr(s8 0 1 2 0 1 2 0 1 2 0)")547(:doc-example . "(arr-alloc 's8 10 0 1 2)\n; ↳ #arr(s8 0 1 2 0 1 2 0 1 2 0)")
547(:doc-group . array) (:doc-see . arr) (:doc-see . vec-alloc)) cddadr ((:doc-group . list)) max ((:doc-example . "(max 3 1 9 4)\n; ↳ 9")548(:doc-group . array) (:doc-see . arr) (:doc-see . vec-alloc)) cddadr ((:doc-group . list)) memv ((:doc-group . list)
548(:doc-example . "(max 'c 'h 'z 'a)\n; ↳ z") (:doc-example . "(max \"t\" \"g\" \"a\")\n; ↳ \"t\"")549(:doc-see . member) (:doc-see . memq)) max ((:doc-example . "(max 3 1 9 4)\n; ↳ 9") (:doc-example . "(max 'c 'h 'z 'a)\n; ↳ z")
549(:doc-group . compare) (:doc-see . min)) memv ((:doc-group . list) (:doc-see . member) (:doc-see . memq)) closure? ((:doc-example . "(closure? closure?)\n; ↳ T")550(:doc-example . "(max \"t\" \"g\" \"a\")\n; ↳ \"t\"")
551(:doc-group . compare)
552(:doc-see . min)) closure? ((:doc-example . "(closure? closure?)\n; ↳ T")
550(:doc-example . "(closure? length)\n; ↳ NIL") (:doc-group . type) (:doc-see . fn?)) read-all ((:doc-example . "; read current process' status file on Plan 9\n(def status (file (str \"/proc/\" (getpid) \"/status\")))\n(read-all status)\n; ↳ (sl glenda Pread 40 0 4940 0 0 0 1856 10 10)")553(:doc-example . "(closure? length)\n; ↳ NIL") (:doc-group . type) (:doc-see . fn?)) read-all ((:doc-example . "; read current process' status file on Plan 9\n(def status (file (str \"/proc/\" (getpid) \"/status\")))\n(read-all status)\n; ↳ (sl glenda Pread 40 0 4940 0 0 0 1856 10 10)")
551(:doc-group . io) (:doc-see . io-read-all)) help-print-header ((:doc-group . doc)) arg-counts ((:doc-group . builtin)) sleep ((:doc-example . "(sleep 0.1) ; sleep for 100ms")554(:doc-group . io) (:doc-see . io-read-all)) help-print-header ((:doc-group . doc)) arg-counts ((:doc-group . builtin)) sleep ((:doc-example . "(sleep 0.1) ; sleep for 100ms")
552(:doc-group . time)) rune? ((:doc-group . type) (:doc-group . string) (:doc-see . rune)) s16 ((:doc-group . number)555(:doc-group . time)) rune? ((:doc-group . type) (:doc-group . string) (:doc-see . rune)) s16 ((:doc-group . number)
@@ -673,7 +676,7 @@ abs #fn("A180EL236080U:80:" 6) add-exit-hook · 120 unmodified lines
673#fn("A18070PI047160:" #(*exit-hooks* void) 6) any #fn("A281B;3H048081<51;J<04708081=62:" #(any) 7)676#fn("A18070PI047160:" #(*exit-hooks* void) 6) any #fn("A281B;3H048081<51;J<04708081=62:" #(any) 7)
674append #fn("r0DIDIb5b6852085>1_486218685>2_4D9D9P86<878052487=:" #(#fn("A281J5080:81<D9P8086N490<8681=62:" copy- 8)677append #fn("r0DIDIb5b6852085>1_486218685>2_4D9D9P86<878052487=:" #(#fn("A281J5080:81<D9P8086N490<8681=62:" copy- 8)
675#fn("A281=370D9@<08081<N4DI:490<91<8081<5281=62:" append- 8)) 10)678#fn("A281=370D9@<08081<N4DI:490<91<8081<5281=62:" append- 8)) 10)
676arg-counts #table(vec? 1 bound? 1 sym? 1 eqv? 2 equal? 2 compare 2 not 1 car 1 cons 2 set-cdr! 2 cadr 1 fn? 1 num? 1 nan? 1 set-car! 2 eq? 2 cons? 1 builtin? 1 fixnum? 1 atom? 1 cdr 1 div0 2)679arg-counts #table(bound? 1 sym? 1 car 1 cons 2 cadr 1 nan? 1 fixnum? 1 atom? 1 cdr 1 div0 2 vec? 1 equal? 2 eqv? 2 compare 2 not 1 set-cdr! 2 num? 1 fn? 1 set-car! 2 eq? 2 cons? 1 builtin? 1)
677arg-error #fn("r0202180P61:" #(#fn(raise) arg-error) 7) argc-error680arg-error #fn("r0202180P61:" #(#fn(raise) arg-error) 7) argc-error
678#fn("A27080218181Kl237022@402364:" #(compile-error " expects " " argument." " arguments.") 10)681#fn("A27080218181Kl237022@402364:" #(compile-error " expects " " argument." " arguments.") 10)
679args_auto41# #:args_auto41# args_auto53# #:args_auto53# arr?682args_auto41# #:args_auto41# args_auto53# #:args_auto53# arr?
@@ -825,7 +828,7 @@ fn-disasm #fn("O100030004000W1000J70D9?14W2000J70DA?24W3000J70D9?34DIDIDIDIb:b;2 · 145 unmodified lines
825#fn(ash)) ref-s32-LE 12) #fn("A220218081EMGE52218081KMGF852M61:" #(#fn(s16)828#fn(ash)) ref-s32-LE 12) #fn("A220218081EMGE52218081KMGF852M61:" #(#fn(s16)
826#fn(ash)) ref-s16-LE 10)829#fn(ash)) ref-s16-LE 10)
827#fn("A170718022F@53F52324252666:" #(str-pad num->str :base :align :right :fill #\0) hex5 11)830#fn("A170718022F@53F52324252666:" #(str-pad num->str :base :align :right :fill #\0) hex5 11)
828#table(loada.l loada call.l call jmp.l jmp box.l box argc.l argc loadv.l loadv loadg.l loadg seta.l seta aref2 "aref 2" tcall.l tcall sub2 "sub 2" add2 "add 2" loadc.l loadc brn.l brn load0 "loadi8 0" brnn.l brnn setg.l setg vargc.l vargc load1 "loadi8 1" brne.l brne)831#table(call.l call box.l box loadg.l loadg aref2 "aref 2" tcall.l tcall brn.l brn load0 "loadi8 0" brnn.l brnn brne.l brne loada.l loada jmp.l jmp argc.l argc loadv.l loadv seta.l seta sub2 "sub 2" add2 "add 2" loadc.l loadc setg.l setg vargc.l vargc load1 "loadi8 1")
829princ " > " " // PC" newline fn-disasm :ip :readable :level #fn(fn-code)832princ " > " " // PC" newline fn-disasm :ip :readable :level #fn(fn-code)
830#fn(fn-vals) #fn("A180\\3R080[JL070504718022D923902491KM67:758061:" #(newline fn-disasm :ip833#fn(fn-vals) #fn("A180\\3R080[JL070504718022D923902491KM67:758061:" #(newline fn-disasm :ip
831:readable :level print) print-val 13)834:readable :level print) print-val 13)
src/docs.sl+17−1639
@@ -52,1642 +52,20 @@ · 51 unmodified lines
52(doc-group doc52(doc-group doc
53 «Writing and reading documentation.»)53 «Writing and reading documentation.»)
54 54
55(doc-group prop55(load "../src/docs_array.sl")
56 «Dealing with properties of symbols.»)56(load "../src/docs_compress.sl")
57 57(load "../src/docs_debug.sl")
58(doc-group compress58(load "../src/docs_io.sl")
59 «Compression.»)59(load "../src/docs_list.sl")
60 60(load "../src/docs_misc.sl")
61(defdoc (lz-pack data (level 0))61(load "../src/docs_number.sl")
62 «Return data compressed using Lempel-Ziv.62(load "../src/docs_ops.sl")
63 63(load "../src/docs_random.sl")
64 The data must be an array, returned value will have the same type.64(load "../src/docs_seq.sl")
65 The optional `level` is between `0` and `10`. With `level` set to65(load "../src/docs_string.sl")
66 `0` a simple LZSS using hashing will be performed. Levels between66(load "../src/docs_struct.sl")
67 `1` and `9` offer a trade-off between time/space and ratio. Level67(load "../src/docs_sys.sl")
68 `10` is optimal but very slow.»68(load "../src/docs_table.sl")
69 :doc-group compress)69(load "../src/docs_time.sl")
70 70(load "../src/docs_type.sl")
71(defdoc (lz-unpack data :to destination))71(load "../src/docs_vm.sl")
72(defdoc (lz-unpack data :size decompressed-bytes)
73 «Return decompressed data previously compressed using lz-pack.
74
75 Either destination for the decompressed data or the expected size of
76 the decompressed data must be specified. In the latter case a new
77 array is allocated.»
78 :doc-group compress)
79
80(doc-group random
81 «Random numbers generation.»)
82
83(defdoc *random-state*
84 «The random state of the current process.
85
86 The state isn't set (is `NIL`) until a call is made to any function
87 that uses it.»
88 :doc-group random
89 :doc-see make-random-state
90 :doc-see random-state?)
91
92(defdoc (make-random-state (state NIL))
93 «Return a new random state.
94
95 If `state` is `NIL`, a copy of the random state of the current process
96 (`*random-state*`) is returned. If `state` is `T`, the returned random
97 state is a new one that has been randomly initialized. If an already
98 existing random state is passed, the returned value is a copy of that
99 state.»
100 :doc-group random
101 :doc-see *random-state*
102 :doc-see random-state?
103 :doc-see random)
104
105(defdoc (random-state? state)
106 «Return `T` if the argument is a random state object, `NIL` otherwise.»
107 :doc-example
108 «(random-state? 1)
109 ; ↳ NIL»
110 :doc-example
111 «(random-state? (make-random-state))
112 ; ↳ T»
113 :doc-example
114 «(random-state? *random-state*)
115 ; ↳ T»
116 :doc-group random
117 :doc-see *random-state*
118 :doc-see make-random-state)
119
120(defdoc (random max (state NIL))
121 «Return a random number in the range `[0, max]` (inclusive).
122
123 The result is either an integer or a floating point number, depending
124 on the type of the `max` argument, which has to be a positive number.
125
126 Optional `state` can be specified, otherwise the random state of the
127 current process (`*random-state*`) is used. State will be modified
128 in-place.»
129 :doc-example
130 «(random 1)
131 ; ↳ 1»
132 :doc-example
133 «(random 10000000000000000000000000000000000)
134 ; ↳ 5312781302474765749507273681609477»
135 :doc-example
136 «(random 1.0)
137 ; ↳ 0.69517»
138 :doc-group random
139 :doc-see make-random-state)
140
141(doc-group sys
142 «OS-specific functions.»)
143
144(defdoc +endianness+
145 «Endianess of the CPU the VM is running on, a constant.
146
147 Set to either `:big-endian` or `:little-endian`.»
148 :doc-group sys)
149
150(defdoc *directory-separator*
151 «OS-specific path separator.
152
153 It is preferred over hardcoded `"/"`, for portability.»
154 :doc-group sys
155 :doc-see *linefeed*)
156
157(defdoc *linefeed*
158 «OS-specific _line_ _feed_ value.
159
160 It is preferred over hardcoded `"\n"`, for portability.»
161 :doc-group sys
162 :doc-see newline
163 :doc-see *directory-separator*)
164
165(defdoc *print-width*
166 «Current maximal visible width (in terminal cells) of strings printed or `NIL`
167 if strings are to be printed in full.
168
169 Truncation does not occur in the middle of a codepoint or a grapheme cluster.
170
171 Note: if a string contains an invalid rune or a control character for which
172 its width is undefined, the string is printed in full if the rune in question
173 would fit otherwise.»
174 :doc-example
175 «(with-bindings ((*print-width* 3)) (princ "abcde"))
176 ; ‼ abc...»
177 :doc-example
178 «(with-bindings ((*print-width* 3)) (princ "ab𲎿"))
179 ; ‼ ab...»
180 :doc-group io
181 :doc-see princ)
182
183(defdoc +os-name+
184 «The name of the operating system this StreetLISP VM executable was
185 built for.
186
187 It's set to a lowercase string and its value is considered "best
188 effort" - it might not always be accurate.
189
190 Possible values: `"unknown"`, `"plan9"`, `"linux"`, `"openbsd"`,
191 `"netbsd"`, `"dragonflybsd"`, `"freebsd"`, `"haiku"`, `"macosx"`,
192 `"macos"`, `"dos"`.»
193 :doc-group sys
194 :doc-see +os-version+)
195
196(defdoc +os-version+
197 «The "version" of the operating system StreetLISP VM is running on.
198
199 The availability of the constant and its value depends on the
200 operating system and is only provided for the user to see. No logic
201 should depend on it.»
202 :doc-example
203 «; on Alpine Linux
204 +os-version+
205 ; ↳ "6.14.5-0-edge" ; kernel version»
206 :doc-example
207 «; on 9front
208 +os-version+
209 ; ↳ NIL ; 9front does not define one»
210 :doc-group sys
211 :doc-see +os-name+)
212
213(defdoc (os-getenv name)
214 «Return the value of the environment variable `name` or `NIL` if it's
215 not set.»
216 :doc-group sys
217 :doc-see os-setenv)
218
219(defdoc (os-setenv name value)
220 «Add or replace the value of the environment variable `name` to
221 `value`.
222
223 If `value` is `NIL`, the variable is deleted from the environment if
224 it exists.»
225 :doc-group sys
226 :doc-see os-getenv)
227
228(defdoc (exit (msg NIL) (code 0))
229 «Terminate the process with the specified message and code. Does not return.
230
231 The message is expected to be a non-empty string in case of an error.
232 The code is expected to be a positive integer in case of an error.»
233 :doc-example
234 «(exit) ; exit with code 0 (message '' on Plan 9)»
235 :doc-example
236 «(exit "error") ; exit with code 1 (message "error" on Plan 9)»
237 :doc-group sys)
238
239(defdoc (getpid)
240 «Return the process ID of the StreetLISP VM within the operating system
241 it's running on.»
242 :doc-group sys)
243
244(doc-group io
245 «Files and I/O functionality.»)
246
247(defdoc (path-delete path)
248 «Delete the name from the filesystem.
249
250 Throws an IO error if the path does not exist or it failed to be
251 removed.»
252 :doc-group io
253 :doc-see path-exists?
254 :doc-see path-rename)
255
256(defdoc (path-rename old new)
257 «Rename a file or a directory.
258
259 Throws an IO error if the path does not exist or it failed to be
260 rename. On most operating systems (not Plan 9), files can be moved
261 between directories.»
262 :doc-group io
263 :doc-see path-delete
264 :doc-see path-exists?)
265
266(defdoc (path-exists? path)
267 «Return `T` if `path` exists on the filesystem, `NIL` otherwise.»
268 :doc-group io
269 :doc-see file
270 :doc-see path-delete)
271
272(defdoc (path-cwd (to NIL))
273 «Return the full path to the current directory of the process, or
274 change it to the path specified with `to` argument.»
275 :doc-group io
276 :doc-see path-exists?)
277
278(defdoc (file path (mode #o644)
279 (:read NIL)
280 (:write NIL)
281 (:create NIL)
282 (:truncate NIL)
283 (:append NIL))
284 «Open a file for I/O.
285
286 An `io` object is returned. Without any modes specified the file
287 must already exist and is opened in read-only mode.
288
289 Files are created with the default mode bits #o644.»
290 :doc-group io)
291
292(defdoc (io? term)
293 «Return `T` if `term` is of `io` type, `NIL` otherwise.»
294 :doc-group io
295 :doc-group type)
296
297(defdoc (io->str io)
298 «Return the data of the in-memory `io` buffer as a string.»
299 :doc-group io)
300
301(defdoc (io-eof? io)
302 «Return `T` if `io` is currently in the "end of file" state, `NIL`
303 otherwise.»
304 :doc-group io)
305
306(defdoc (eof? v)
307 «Return `T` if the argument is `#<eof>`, `NIL` otherwise.
308
309 This object is returned by I/O functions to signal end of file,
310 where applicable.»
311 :doc-group io
312 :doc-group type)
313
314(defdoc (buffer)
315 «Return an in-memory buffer for I/O, of `io` type.
316
317 In the first form an empty buffer for both reading and writing is returned.
318
319 A read-only buffer pointing at the underlying data of `v` is returned in
320 the second form. Optionally, the range of the data (measured in bytes)
321 available when accessing the buffer may be limited by using `:start` and/or
322 `:end` keyworded arguments.»
323 :doc-example
324 «(def b (buffer))
325 (io-write b #vu8(#x68 #x65 #x6c #x6c #x6f))
326 ; ↳ 5
327 (io->str b)
328 ; ↳ "hello"»
329 :doc-example
330 «(def b (buffer (arr 'f32 1.0 2.0 3.0 -4.0)))
331 (io-pos! b 8)
332 (io-read b 'p32 2)
333 ; ↳ #arr(p32 #x40400000 #xC0800000)»
334 :doc-group io
335 :doc-see io->str)
336
337(defdoc (buffer v (:start NIL) (:end NIL)))
338
339(defdoc (length seq)
340 «Return the length of the sequence.
341
342 String's length is measured in UTF-8 codepoints. For tables the number
343 of key-value pairs is returned.
344
345 Note: for circular lists the result is `NIL`. A type error exception is
346 thrown on improper lists, which are not considered valid sequences.»
347 :doc-example
348 «(length "абвгд")
349 ; ↳ 5»
350 :doc-example
351 «(length #(abc 123))
352 ; ↳ 2»
353 :doc-example
354 «(length #table(0 a 1 b 2 c))
355 ; ↳ 3»
356 :doc-example
357 «(length (arr 'u32 1 2 3 4))
358 ; ↳ 4»
359 :doc-example
360 «(length '(1 2 3 4 5))
361 ; ↳ 5»
362 :doc-example
363 «(length '(1 2 3 4 . 5)) ; improper list
364 ; ‼ type error: expected cons, got fixnum: 5»
365 :doc-example
366 «(length '#0=(1 . #0#)) ; circular list
367 ; ↳ NIL»
368 :doc-group array
369 :doc-group list
370 :doc-group table
371 :doc-see proper-list?)
372
373(defdoc (assq key lst)
374 «Return a pair of a matching key and the associated value, or `NIL` if
375 none matched. Keys are compared using `eq?`.»
376 :doc-group list
377 :doc-see assoc
378 :doc-see assv)
379
380(defdoc (memq item lst)
381 «Return the tail of a list beginning with the item, or `NIL` otherwise.
382 List elements are compared to the `item` using `eq?`.»
383 :doc-group list
384 :doc-see member
385 :doc-see memv)
386
387(defdoc NIL
388 «An empty list. Can be used as the opposite of T in boolean
389 expressions.»
390 :doc-example
391 «(not NIL)
392 ; ↳ T»
393 :doc-example
394 «(if NIL 'yes 'no)
395 ; ↳ no»
396 :doc-example
397 «(car NIL)
398 ; ↳ NIL»
399 :doc-example
400 «(cdr NIL)
401 ; ↳ NIL»
402 :doc-see T)
403
404(defdoc T
405 «A boolean "true".»
406 :doc-example
407 «(not T)
408 ; ↳ NIL»
409 :doc-example
410 «(if T 'yes 'no)
411 ; ↳ yes»
412 :doc-see NIL)
413
414(doc-group string
415 «Strings and runes.»)
416
417(defdoc (str . terms)
418 «Return concatenation of terms formatted as strings.
419
420 This is equivalent to `(princ terms…)`, except the string is
421 _returned_, rather than printed.»
422 :doc-example
423 «(str "a" 'b 1 #(0))
424 ; ↳ "ab1#(0)"»
425 :doc-group string)
426
427(defdoc (str-width s)
428 «Return the number of columns needed to represent a string or a rune.
429
430 If a non-printable control rune is encountered, the result is `NIL`,
431 else it is a non-negative integer. Rune `#\null` is considered of width zero.»
432 :doc-example
433 «(str-width #\й)
434 ; ↳ 1»
435 :doc-example
436 «(str-width "⌛!")
437 ; ↳ 3»
438 :doc-example
439 «(str-width "nope\n")
440 ; ↳ NIL»
441 :doc-group string)
442
443(defdoc (str-rune s n)
444 «Return the nth rune of the string.
445
446 Throws an exception if the index `n` is out of bounds.»
447 :doc-example
448 «(str-rune "йцукен" 3)
449 ; ↳ #\к»
450 :doc-group string
451 :doc-see str-sub)
452
453(defdoc (str-sub s start (end NIL))
454 «Return the portion of the string within the specified bounds.
455
456 The `start` and `end` index by rune. Specifying any index out of bounds
457 of the string will result in an exception thrown.
458
459 If `end` isn't specified the portion is assumed to begin at `start`
460 until the end of the original string.»
461 :doc-example
462 «(str-sub "hello" 2)
463 ; ↳ "llo"»
464 :doc-example
465 «(str-sub "hello" 3 3)
466 ; ↳ ""»
467 :doc-example
468 «(str-sub "hello" 2 4)
469 ; ↳ "ll"»
470 :doc-group string
471 :doc-see str-rune)
472
473(defdoc (str-utf8? s)
474 «Return `T` if `s` is a valid UTF-8 string, `NIL` otherwise.»
475 :doc-example
476 «(str-utf8? "привет")
477 ; ↳ T»
478 :doc-example
479 «(str-utf8? "при\xffвет")
480 ; ↳ NIL»
481 :doc-group string
482 :doc-see str?)
483
484(defdoc (str->num s (:base NIL))
485 «Return the number using the radix `base` in the string `s`.
486
487 Returns `NIL` if the number could not be parsed. Any number of leading
488 and/or trailing whitespace runes is allowed and those will be ignored.»
489 :doc-example
490 «(str->num "1.2")
491 ; ↳ 1.2»
492 :doc-example
493 «(str->num "#x123")
494 ; ↳ 291»
495 :doc-example
496 «(str->num "ffff" :base 16)
497 ; ↳ 65535»
498 :doc-example
499 «(str->num "777" :base 8)
500 ; ↳ 511»
501 :doc-group string
502 :doc-see num->str)
503
504(defdoc (sym term . rest)
505 «Return a symbol with the name being the concatenation of terms
506 formatted as strings.
507
508 This is equivalent to `(sym (str …))`.»
509 :doc-example
510 «(sym "a" 'b 1)
511 ; ↳ ab1»
512 :doc-group misc
513 :doc-see sym?)
514
515(doc-group struct
516 «Declaring and manipulating structures.»)
517
518(defdoc (defstruct name
519 docs…
520 options…
521 (slot-1 DEFAULT)
522 slot-2
523 slot-3))
524 ',sym ',doc ',callvars
525
526(defdoc (defstruct name (:type vec)
527 (:named T named-supplied)
528 (:constructor T constructor-supplied)
529 (:conc-name T conc-name-supplied)
530 (:predicate T predicate-supplied)
531 . slots)
532 «Declare a new structure type with the specified name and slots.
533
534 The default underlying type is a "named" vector (`:type vec`), where
535 the first element is the name of the structure's type, the rest are
536 the keyworded slot values. A list with slot values alone can be used
537 instead by adding `:type list` option. The list will not contain the
538 name of the struct by default, which can be enabled with `:named T`
539 option.
540
541 As an example, the following declaration generates the default
542 constructor for a structure of three slots, with one of them (`c`)
543 having a non-`NIL` default value and marked as read-only:
544
545 (defstruct blah "Return stuff." :doc-group stuff a b (c 1 :read-only T))
546 ; (make-blah (:a NIL) (:b NIL) (:c 1))
547 ; (blah-a s)
548 ; (blah-b s)
549 ; (blah-c s)
550 ; (blah-a! s new-a)
551 ; (blah-b! s new-b)
552
553 Slot's options, if any, should be specified after its default value.
554 Supported options are:
555
556 ; mark the slot as read-only
557 ; its value can be read, but trying to modify it will throw an error
558 … :read-only T
559
560 The constructor can be changed in several ways:
561
562 ; disable the constructor altogether
563 (defstruct blah :constructor NIL a b c)
564 ; only change its name
565 (defstruct blah :constructor blargh a b c)
566 ; rename AND avoid using keywords
567 (defstruct blah :constructor (blah a b c) a b c)
568
569 The option `:conc-name` specifies the slot accessor/setter prefix,
570 which defaults to `structname-`. Prefix can be disabled entirely with
571 `:conc-name NIL`.
572
573 Slot setters are generated for writable slots by appending `!`
574 (exclamation mark) to the accessor's name.
575
576 Default predicate can be disabled or its name, which defaults to
577 `structname?`, changed:
578
579 ; use "blargh?" instead of "blah?"
580 (defstruct blah :predicate blargh? a b c)
581 ; without predicate
582 (defstruct blah :predicate NIL a b c)»
583 :doc-group struct)
584
585(defdoc (const? term)
586 «Return `T` if the term refers to a constant, `NIL` otherwise.
587
588 Constants cannot be modified with `set!`. Trying to do so will result
589 in an exception.»
590 :doc-example
591 «(const? 12345) ; a number
592 ; ↳ T»
593 :doc-example
594 «(const? 'const?) ; a function
595 ; ↳ NIL»
596 :doc-example
597 «(const? 'pi) ; a mathematical constant
598 ; ↳ T»
599 :doc-group type)
600
601(defdoc (bignum? v)
602 «Return `T` if the argument is a bignum, `NIL` otherwise.»
603 :doc-group type
604 :doc-group number
605 :doc-see bignum)
606
607(defdoc (int? v)
608 «Return `T` if the argument is an integer, `NIL` otherwise.»
609 :doc-group type
610 :doc-group number
611 :doc-see int-valued?)
612
613(defdoc (str? v)
614 «Return `T` if the argument is a string, `NIL` otherwise.»
615 :doc-group type
616 :doc-see str
617 :doc-see str-utf8?)
618
619(defdoc (gensym? v)
620 «Return `T` if the argument is a gensym, `NIL` otherwise.»
621 :doc-group type
622 :doc-see sym?
623 :doc-see sym)
624
625(defdoc (ptr? v)
626 «Return `T` if the argument is an abstract pointer, `NIL` otherwise.»
627 :doc-group type
628 :doc-group number
629 :doc-see ptr)
630
631(defdoc (table? v)
632 «Return `T` if the argument is a table, `NIL` otherwise.»
633 :doc-group type
634 :doc-group table
635 :doc-see table)
636
637(defdoc (keyword? v)
638 «Return `T` if the argument is a keyword, `NIL` otherwise.»
639 :doc-group type)
640
641(defdoc +most-positive-fixnum+
642 «A constant integer closest to positive infinity that can be
643 represented by fixnum type on this particular platform.»
644 :doc-group number
645 :doc-see +most-negative-fixnum+)
646
647(defdoc +most-negative-fixnum+
648 «A constant integer closest to negative infinity that can be
649 represented by fixnum type on this particular platform.»
650 :doc-group number
651 :doc-see +most-positive-fixnum+)
652
653(defdoc +f32-epsilon+
654 «A smallest positive floating point number such that
655 `(+ 1.0f +f32-epsilon+)` is not equal to `1.0f`.»
656 :doc-group number
657 :doc-see +f64-epsilon)
658
659(defdoc +f64-epsilon+
660 «A smallest positive floating point number such that
661 `(+ 1.0 +f64-epsilon+)` is not equal to `1.0`.»
662 :doc-group number
663 :doc-see +f32-epsilon)
664
665(defdoc (fixnum (n 0))
666 «Construct a fixnum.»
667 :doc-group number
668 :doc-see fixnum?)
669
670(defdoc (u8 (n 0))
671 «Construct a 8-bit unsigned number.»
672 :doc-group number
673 :doc-see s8)
674
675(defdoc (s8 (n 0))
676 «Construct a 8-bit signed number.»
677 :doc-group number
678 :doc-see u8)
679
680(defdoc (u16 (n 0))
681 «Construct a 16-bit unsigned number.»
682 :doc-group number
683 :doc-see s16)
684
685(defdoc (s16 (n 0))
686 «Construct a 16-bit signed number.»
687 :doc-group number
688 :doc-see u16)
689
690(defdoc (u32 (n 0))
691 «Construct a 32-bit unsigned number.»
692 :doc-group number
693 :doc-see s32)
694
695(defdoc (s32 (n 0))
696 «Construct a 32-bit signed number.»
697 :doc-group number
698 :doc-see u32)
699
700(defdoc (u64 (n 0))
701 «Construct a 64-bit unsigned number.»
702 :doc-group number
703 :doc-see s64)
704
705(defdoc (s64 (n 0))
706 «Construct a 64-bit signed number.»
707 :doc-group number
708 :doc-see u64)
709
710(defdoc (f32 (n 0.0))
711 «Construct a 32-bit floating point number.»
712 :doc-group number
713 :doc-see f64)
714
715(defdoc (f64 (n 0.0))
716 «Construct a 64-bit floating point number.»
717 :doc-group number
718 :doc-see f32)
719
720(defdoc (p32 (n 0))
721 «Construct a 32-bit abstract pointer value.»
722 :doc-group number
723 :doc-see p64
724 :doc-see ptr)
725
726(defdoc (p64 (n 0))
727 «Construct a 64-bit abstract pointer value.»
728 :doc-group number
729 :doc-see p32
730 :doc-see ptr)
731
732(defdoc (ptr (n 0))
733 «Construct an abstract pointer value. The bit width is either 32-bit
734 or 64-bit, depending on the platform the code is executing on.
735
736 Note: certain arithmetic operations on pointers, such as division and
737 multiplication, will throw an error. This is done on purpose since
738 doing that on pointers rarely makes sense.»
739 :doc-group number
740 :doc-see p32
741 :doc-see p64
742 :doc-see ptr?)
743
744(defdoc (rune (n #xfffd))
745 «Construct a rune from a Unicode code point. Without code point
746 specified, an "invalid" rune is returned.»
747 :doc-group string
748 :doc-see rune?)
749
750(defdoc (bignum (n 0))
751 «Construct a bignum. As opposed to a fixnum, its value is not limited.»
752 :doc-group number
753 :doc-see bignum?)
754
755(defdoc (floor x)
756 «Return the largest integer that is less than or equal to `x`.
757
758 Infinity and NaN `floor` to themselves.»
759 :doc-example
760 «(floor 1.2)
761 ; ↳ 1.0»
762 :doc-example
763 «(floor -1.2)
764 ; ↳ -2.0»
765 :doc-example
766 «(floor -5)
767 ; ↳ -5.0»
768 :doc-group number
769 :doc-see ceiling)
770
771(defdoc (ceiling x)
772 «Return the smallest integer that is greater than or equal to `x`.
773
774 Infinity and NaN `ceiling` to themselves.»
775 :doc-example
776 «(ceiling 1.2)
777 ; ↳ 2.0»
778 :doc-example
779 «(ceiling -1.2)
780 ; ↳ -1.0»
781 :doc-example
782 «(ceiling -5)
783 ; ↳ -5.0»
784 :doc-group number
785 :doc-see floor)
786
787(defdoc (ash int nbits)
788 «Return the integer shifted by the specified number of bits to the
789 right (negative `nbits`) or left (positive `nbits`).»
790 :doc-example
791 «(ash -3 3)
792 ; ↳ -24»
793 :doc-example
794 «(ash 1 3)
795 ; ↳ 8»
796 :doc-group number)
797
798(defdoc (lognot int)
799 «Return the result of bitwise NOT (complement) operation on an integer.»
800 :doc-example
801 «(lognot 0)
802 ; ↳ -1»
803 :doc-example
804 «(lognot #s8(63))
805 ; ↳ #s8(-64)»
806 :doc-example
807 «(lognot #u16(32767))
808 ; ↳ #u16(32768)»
809 :doc-group number)
810
811(defdoc (logior . ints)
812 «Return the result of bitwise OR (inclusive OR) operation on integers.»
813 :doc-example
814 «(logior)
815 ; ↳ 0»
816 :doc-example
817 «(logior 2)
818 ; ↳ 2»
819 :doc-example
820 «(logior 2 3)
821 ; ↳ 3»
822 :doc-example
823 «(logior 2 3 4)
824 ; ↳ 7»
825 :doc-group number)
826
827(defdoc (logand . ints)
828 «Return the result of bitwise AND operation on integers.»
829 :doc-example
830 «(logand)
831 ; ↳ 0»
832 :doc-example
833 «(logand 2)
834 ; ↳ 2»
835 :doc-example
836 «(logand 2 3)
837 ; ↳ 2»
838 :doc-example
839 «(logand 2 3 4)
840 ; ↳ 0»
841 :doc-group number)
842
843(defdoc (logxor . ints)
844 «Return the result of bitwise XOR (exclusive OR) operation on integers.»
845 :doc-example
846 «(logxor)
847 ; ↳ 0»
848 :doc-example
849 «(logxor 2)
850 ; ↳ 2»
851 :doc-example
852 «(logxor 2 3)
853 ; ↳ 1»
854 :doc-example
855 «(logxor 2 3 4)
856 ; ↳ 5»
857 :doc-group number)
858
859(defdoc +pi+
860 «Mathematical constant π.»
861 :doc-group number)
862
863(defdoc (acos x)
864 «Return the arc cosine of `x` in radians.»
865 :doc-group number)
866
867(defdoc (asin x)
868 «Return the arc sine of `x` in radians.»
869 :doc-group number)
870
871(defdoc (atan x)
872 «Return the arc tangent of `x` in radians.»
873 :doc-group number)
874
875(defdoc (atan y x)
876 «Return the arc tangent of `y/x` in radians.»
877 :doc-group number)
878
879(defdoc (cos r)
880 «Return the cosine of `r`, where `r` is given in radians.»
881 :doc-group number)
882
883(defdoc (sin r)
884 «Return the sine of `r`, where `r` is given in radians.»
885 :doc-group number)
886
887(defdoc (tan r)
888 «Return the tangent of `r`, where `r` is given in radians.»
889 :doc-group number)
890
891(defdoc (cosh x)
892 «Return the hyperbolic cosine of `x`.»
893 :doc-group number)
894
895(defdoc (sinh r)
896 «Return the hyperbolic sine of `x`.»
897 :doc-group number)
898
899(defdoc (tanh r)
900 «Return the hyperbolic tangent of `x`.»
901 :doc-group number)
902
903(defdoc (sqrt x)
904 «Return the square root of `x`.»
905 :doc-example
906 «(sqrt 9.0)
907 ; ↳ 3.0»
908 :doc-group number)
909
910(defdoc (exp p)
911 «Return the exponential - value of `e` (natural logarithms base) raised
912 to the power of `p`.»
913 :doc-example
914 «(exp 1)
915 ; ↳ 2.71828… ; e»
916 :doc-group number)
917
918(defdoc (expt x p)
919 «Return the value of `x` raised to the power of `p`.»
920 :doc-example
921 «(expt 3 3) ; cube of 3
922 ; ↳ 27»
923 :doc-example
924 «(expt 27 (/ 1 3)) ; cube root of 27
925 ; ↳ 3»
926 :doc-group number)
927
928(defdoc (log x (base (exp 1)))
929 «Return the logarithm of `x` in `base`.
930
931 Default base is `e`, returning natural logarithm of the first
932 argument.»
933 :doc-example
934 «(log 100 10)
935 ; ↳ 2.0»
936 :doc-example
937 «(log 256 2)
938 ; ↳ 8.0»
939 :doc-example
940 «(log (exp 4))
941 ; ↳ 4.0»
942 :doc-group number)
943
944(defdoc (truncate x)
945 «Return the integer value of `x` rounded toward zero.
946
947 If `x` is already an integer (or infinite, or NaN), result is `x`.»
948 :doc-example
949 «(truncate -123.45)
950 ; ↳ -123»
951 :doc-example
952 «(truncate 299.9)
953 ; ↳ 299»
954 :doc-group number)
955
956(defdoc (int-valued? x)
957 «Return `T` if `x` is a number and is equal (as in `=`) to an
958 integer value of `x`.»
959 :doc-example
960 «(int-valued? -123.0)
961 ; ↳ T»
962 :doc-example
963 «(int-valued? -123.1)
964 ; ↳ NIL»
965 :doc-group number
966 :doc-see int?)
967
968(doc-group vm
969 «VM-related functions.»)
970
971(defdoc (environment)
972 «Return the list of all bound top level symbols.»
973 :doc-group debug
974 :doc-group vm
975 :doc-see print-stack-trace)
976
977(defdoc (vm-stats (io *io-out*))
978 «Print various VM-related information, such as the number of GC
979 calls so far, heap and stack size, etc.»
980 :doc-group debug
981 :doc-group vm)
982
983(defdoc (tag-of v)
984 «Return the internal VM tag of the value.»
985 :doc-example
986 «(tag-of 1)
987 ; ↳ fixnum»
988 :doc-example
989 «(tag-of NIL)
990 ; ↳ special»
991 :doc-example
992 «(tag-of "hello")
993 ; ↳ cvalue»
994 :doc-example
995 «(tag-of (s32 1))
996 ; ↳ unboxed»
997 :doc-group vm
998 :doc-see type-of)
999
1000(defdoc (builtin sym)
1001 «Return the builtin associated with the symbol.
1002
1003 Throws an exception if no such builtin exists.»
1004 :doc-example
1005 «(builtin 'map)
1006 ; ↳ #fn(map)»
1007 :doc-example
1008 «(builtin 'print)
1009 ; ‼ arguments error: builtin "print" not found»
1010 :doc-group vm)
1011
1012(defdoc (gc)
1013 «Force a garbage collection run.
1014
1015 One does not need to execute this function manually since garbage
1016 collection will happen automatically, based on the amount of data
1017 allocated.»
1018 :doc-group vm
1019 :doc-see vm-stats)
1020
1021(defdoc (*prompt*)
1022 «Function called by REPL to tell the user it's expecting input.
1023
1024 The default `*prompt*` function prints `#;> `, which by itself is a
1025 commented-out expression, allowing the user to copy-paste the entire
1026 line (with the prompt) to re-evaluate.»
1027 :doc-group vm
1028 :doc-see *interactive*)
1029
1030(defdoc *interactive*
1031 «Variable indicating whether VM is running in "interactive" mode (`T`,
1032 REPL is active) or not (`NIL`, REPL is not active).
1033
1034 Interactive mode can be forced by adding `-i` as the first command
1035 line argument.»
1036 :doc-group vm
1037 :doc-see *prompt*)
1038
1039(defdoc *argv*
1040 «The list of command line arguments.
1041
1042 If StreetLISP was started in interactive mode without a file specified
1043 for execution, `*argv*` will be a list containing just one value - the
1044 name of the `sl` executable.
1045
1046 Otherwise, the file specified for execution and the rest of the remaining
1047 arguments will form the `*argv*` list.
1048
1049 StreetLISP's own options, such as `-i` and `-H ...` will be stripped
1050 out in any case.»
1051 :doc-example
1052 «; $ sl -i -H 12345
1053 *argv*
1054 ; ↳ ("sl")»
1055 :doc-example
1056 «; $ sl script.sl -i abc
1057 *argv*
1058 ; ↳ ("script.sl" "-i" "abc")»
1059 :doc-group vm
1060 :doc-see *interactive*)
1061
1062(doc-group array
1063 «Arrays and vectors.»)
1064
1065(defdoc (copy-vec vec)
1066 «Return a copy of the vector with the same elements.
1067
1068 No copies of the values themselves are created, the original values
1069 are reused.»
1070 :doc-example
1071 «(def v #vec(1 2 "three"))
1072 (def q (copy-vec v))
1073 (eq? v q)
1074 ; ↳ NIL
1075 (equal? v q)
1076 ; ↳ T
1077 (map eq? v q)
1078 ; ↳ #(T T T)»
1079 :doc-group array)
1080
1081(defdoc (vec-alloc length . rest)
1082 «Construct a vector of the specified `length` by repeating
1083 the elements in `rest`.»
1084 :doc-example
1085 «(vec-alloc 5 2.5)
1086 ; ↳ #(2.5 2.5 2.5 2.5 2.5)»
1087 :doc-example
1088 «(vec-alloc 10 1 2.5 "a" 'b)
1089 ; ↳ #(1 2.5 "a" b 1 2.5 "a" b 1 2.5)»
1090 :doc-group array
1091 :doc-see vec
1092 :doc-see arr-alloc)
1093
1094(defdoc (arr type . rest)
1095 «Construct a packed array containing the specified arguments.
1096
1097 The arguments will be coerced to a single `type` which must be
1098 a fixed-width number or pointer type, or rune.»
1099 :doc-example
1100 «(arr 's8 0 1 2)
1101 ; ↳ #arr(s8 0 1 2)»
1102 :doc-example
1103 «(arr 'rune 0 1 2)
1104 ; ↳ #arr(rune #\nul #\soh #\stx)»
1105 :doc-group array
1106 :doc-see arr-alloc
1107 :doc-see vec)
1108
1109(defdoc (arr-alloc type length . rest)
1110 «Construct a packed array of the specified `length` by repeating
1111 the elements in `rest`.
1112
1113 The arguments will be coerced to a single `type` which must be
1114 a fixed-width number or pointer type, or rune.»
1115 :doc-example
1116 «(arr-alloc 'u16 5 -1)
1117 ; ↳ #arr(u16 65535 65535 65535 65535 65535)»
1118 :doc-example
1119 «(arr-alloc 's8 10 0 1 2)
1120 ; ↳ #arr(s8 0 1 2 0 1 2 0 1 2 0)»
1121 :doc-group array
1122 :doc-see arr
1123 :doc-see vec-alloc)
1124
1125(defdoc *stderr*
1126 «Standard error output IO stream.»
1127 :doc-group io
1128 :doc-see *stdout*
1129 :doc-see *stdin*)
1130
1131(defdoc *io-err*
1132 «Current (default) error output IO stream.
1133
1134 Functions may use `*io-err*` for error output, which then can be
1135 redirected to a different IO using `with-bindings`.»
1136 :doc-group io
1137 :doc-see *io-out*
1138 :doc-see *io-in*
1139 :doc-see with-bindings)
1140
1141(defdoc *stdout*
1142 «Standard output IO stream.»
1143 :doc-group io
1144 :doc-see *stderr*
1145 :doc-see *stdin*)
1146
1147(defdoc *io-out*
1148 «Current (default) output IO stream.
1149
1150 Functions may use `*io-out*` for output, which then can be redirected
1151 to a different IO using either `with-output-to` or (a more general)
1152 `with-bindings`.»
1153 :doc-group io
1154 :doc-see *io-err*
1155 :doc-see *io-in*
1156 :doc-see with-output-to)
1157
1158(defdoc *stdin*
1159 «Standard input IO stream.»
1160 :doc-group io
1161 :doc-see *stdout*
1162 :doc-see *stderr*)
1163
1164(defdoc *io-in*
1165 «Current (default) input IO stream.
1166
1167 Functions may use `*io-in*` for input, which then can be redirected
1168 from a different IO using either `with-input-from` or (a more general)
1169 `with-bindings`.»
1170 :doc-group io
1171 :doc-see *io-out*
1172 :doc-see *io-err*
1173 :doc-see with-input-from)
1174
1175(doc-group time
1176 «Measuring, manipulating and displaying time.»)
1177
1178(defdoc (sleep sec)
1179 «Halt the StreetLISP VM for the specified duration of time in seconds.b»
1180 :doc-example
1181 «(sleep 0.1) ; sleep for 100ms»
1182 :doc-group time)
1183
1184(defdoc (nanoseconds-monotonic)
1185 «Return the number of nanoseconds passed since the first call to this
1186 function.
1187
1188 The first call will always return 0.»
1189 :doc-example
1190 «(nanoseconds-monotonic)
1191 ; ↳ #u64(0)
1192 (nanoseconds-monotonic)
1193 ; ↳ #u64(47840)»
1194 :doc-group time
1195 :doc-see time-now)
1196
1197(defdoc (time-now)
1198 «Return the number of nanoseconds since Epoch (1970-01-01 00:00:00).
1199
1200 This measures the system-wide real (wall-clock) time.»
1201 :doc-example
1202 «(time-now)
1203 ; ↳ 1746494461277334928»
1204 :doc-group time
1205 :doc-see nanoseconds-monotonic)
1206
1207(defdoc (time->str sec)
1208 «Return the number of nanoseconds since Epoch formatted as time and date.
1209
1210 This is the opposite of `str->time`.»
1211 :doc-example
1212 «(time->str (time-now))
1213 ; ↳ "Tue May 6 03:21:01 CES 2025"»
1214 :doc-group time
1215 :doc-see str->time
1216 :doc-see time-now)
1217
1218(defdoc (str->time str)
1219 «Return the number of nanoseconds since Epoch from a time and date
1220 formatted as a string.
1221
1222 Because the supported format is limited, the returned value will have
1223 precision in seconds at most.»
1224 :doc-example
1225 «(str->time "Tue May 6 03:21:01 CES 2025")
1226 ; ↳ 1746494461»
1227 :doc-group time
1228 :doc-see time->str
1229 :doc-see time-now)
1230
1231(defdoc (del! table key)
1232 «Remove any existing mapping for `key` and return the table.»
1233 :doc-example
1234 «(def t #table(a 1 b 2))
1235 (del! t 'c)
1236 ; ↳ #table(b 2 a 1)
1237 (del! t 'b)
1238 ; ↳ #table(a 1)
1239 t
1240 ; ↳ #table(a 1)»
1241 :doc-group table
1242 :doc-see has?
1243 :doc-see get
1244 :doc-see put!)
1245
1246(defdoc (get table key [failed-result])
1247 «Return the value associated with the `key` in the table.
1248
1249 If the key isn't in the table then either return the optional
1250 `failed-result` argument or (if called without the argument) throw a
1251 `key-error` exception.»
1252 :doc-example
1253 «(def t #table(a 1 b 2))
1254 (get t 'a)
1255 ; ↳ 1
1256 (get t 'b NIL)
1257 ; ↳ 2
1258 (get t 'c)
1259 ; ‼ key not found: a
1260 (get t 'c 123)
1261 ; ↳ 123»
1262 :doc-group table
1263 :doc-see has?
1264 :doc-see put!
1265 :doc-see del!)
1266
1267(defdoc (put! table key value)
1268 «Store the value associated with the key and return the table.
1269
1270 Any existing value associated with the key will be replaced.»
1271 :doc-example
1272 «(def t #table(a 1 b 2))
1273 (put! t 'c 3)
1274 ; ↳ #table(c 3 b 2 a 1)
1275 (put! t 'a "hello")
1276 ; ↳ #table(c 3 b 2 a "hello")»
1277 :doc-group table
1278 :doc-see get
1279 :doc-see has?
1280 :doc-see del!)
1281
1282(defdoc (has? table key)
1283 «Return `T` if the table has a value associated with the key, `NIL` otherwise.»
1284 :doc-example
1285 «(def t #table(a 1 b 2))
1286 (has? t 'c)
1287 ; ↳ NIL
1288 (has? t 'a)
1289 ; ↳ T»
1290 :doc-group table
1291 :doc-see get
1292 :doc-see put!
1293 :doc-see del!)
1294
1295(defdoc (table . rest)
1296 «Construct a table from keys from the arguments.
1297
1298 Every two arguments are expected to be a key and a value associated
1299 with that key.»
1300 :doc-example
1301 «(table)
1302 ; ↳ #table()»
1303 :doc-example
1304 «(table 'a 1 'b 2)
1305 ; ↳ #table(a 1 b 2)»
1306 :doc-group table
1307 :doc-see get
1308 :doc-see put!)
1309
1310(defdoc (stacktrace)
1311 «Return the current stack trace.»
1312 :doc-group debug
1313 :doc-see print-stack-trace)
1314
1315(defdoc (str-split str (sep " \n\t\v\f") (:trim NIL))
1316 «Return a list of substrings of `str` by splitting at any character in
1317 the string `sep`. The splitting characters are removed.
1318
1319 By default the string is split on space, line feed (newline),
1320 horizontal and vertical tab, and form feed.
1321
1322 Trim removes empty strings from the list.»
1323 :doc-example
1324 «(str-split "hello world")
1325 ; ↳ ("hello" "world")»
1326 :doc-example
1327 «(str-split "multiple spaces ")
1328 ; ↳ ("multiple" "" "" "spaces" "")»
1329 :doc-example
1330 «(str-split "multiple spaces " :trim T)
1331 ; ↳ ("multiple" "spaces")»
1332 :doc-example
1333 «(str-split "too many vowels" "aeiou")
1334 ; ↳ ("t" "" " m" "ny v" "w" "ls")»
1335 :doc-group string)
1336
1337(defdoc (set-top-level-value! sym expr)
1338 «Evaluate the expression and assign the result to the symbol in the top
1339 level (global) environment.
1340
1341 The use of this function is discouraged. For the usual assignment of
1342 values to names it is recommended instead to use `(def …)` and/or
1343 `(set! …)`.»
1344 :doc-example
1345 «(let {[abc 2]}
1346 (set-top-level-value! 'abc 123)
1347 abc)
1348 ; ↳ 2
1349 abc
1350 ; ↳ 123»
1351 :doc-group misc
1352 :doc-see top-level-value
1353 :doc-see set!)
1354
1355(defdoc (top-level-value sym)
1356 «Return the value bound to the symbol in the top level (global)
1357 environment.»
1358 :doc-example
1359 «(def abc 1)
1360 (let {[abc 2]}
1361 (cons abc (top-level-value 'abc)))
1362 ; ↳ (2 . 1)
1363 abc
1364 ; ↳ 1»
1365 :doc-group misc
1366 :doc-see set-top-level-value!)
1367
1368(defdoc (makunbound sym)
1369 «Make the symbol unbound.»
1370 :doc-example
1371 «(def x 1)
1372 (bound? 'x)
1373 ; ↳ T
1374 x
1375 ; ↳ 1
1376 (makunbound 'x)
1377 (bound? 'x)
1378 ; ↳ NIL
1379 x
1380 ; ‼ eval: variable x has no value»
1381 :doc-group misc
1382 :doc-see bound?)
1383
1384(defdoc (type-of v)
1385 «Return the underlying type of the value.»
1386 :doc-example
1387 «(type-of 1)
1388 ; ↳ fixnum»
1389 :doc-example
1390 «(type-of NIL)
1391 ; ↳ null»
1392 :doc-example
1393 «(type-of T)
1394 ; ↳ bool»
1395 :doc-example
1396 «(type-of "hello")
1397 ; ↳ str»
1398 :doc-example
1399 «(type-of (arr 'u32 0 1 2))
1400 ; ↳ (arr u32)»
1401 :doc-group type
1402 :doc-see size-of)
1403
1404(defdoc (size-of v)
1405 «Return the size of the value in bytes, if applicable.
1406
1407 Works only with C integer types, arrays, strings and in-memory
1408 buffers.»
1409 :doc-example
1410 «(size-of "hello")
1411 ; ↳ 5»
1412 :doc-example
1413 «(size-of (arr 'u32 1 2 3))
1414 ; ↳ 12»
1415 :doc-example
1416 «(def b (buffer))
1417 (io-write b "hello")
1418 (size-of b)
1419 ; ↳ 5»
1420 :doc-group misc
1421 :doc-see type-of)
1422
1423(defdoc (io-filename io)
1424 «Return the filename of the IO object.»
1425 :doc-example
1426 «(def f (file "/dev/random"))
1427 (io-filename f)
1428 ; ↳ "/dev/random"
1429 (io-close f)
1430 (io-filename f) ; preserved even after it's closed
1431 ; ↳ "/dev/random"»
1432 :doc-example
1433 «(io-filename *io-out*)
1434 ; ↳ "*stdout*"»
1435 :doc-group io
1436 :doc-see io-filename!)
1437
1438(defdoc (io-filename! io new-name)
1439 «Change the filename of the IO object, return the new filename.
1440
1441 Changing the filename does not cause any side effects. The filename
1442 is purely informative and does not necessarily reflect the actual
1443 path.»
1444 :doc-example
1445 «(def f (buffer))
1446 (io-filename b)
1447 ; ↳ ""
1448 (io-filename! b "new name") ; change the filename
1449 ; ↳ "new name"
1450 (io-filename b)
1451 ; ↳ "new name"»
1452 :doc-group io
1453 :doc-see io-filename)
1454
1455(defdoc (io-line io)
1456 «Return the current line number of the IO object.
1457
1458 Line number is purely informative and is only being automatically
1459 updated with the files opened for reading. If the cursor position is
1460 changed via `io-skip` or `io-pos!`, the behavior is undefined.»
1461 :doc-group io
1462 :doc-see io-column
1463 :doc-see io-line!)
1464
1465(defdoc (io-line! io new-line-number)
1466 «Change the current line number of the IO object.»
1467 :doc-group io
1468 :doc-see io-line
1469 :doc-see io-column!)
1470
1471(defdoc (io-column io)
1472 «Return the current column number of the IO object.
1473
1474 Column number is purely informative and is only being automatically
1475 updated with the files opened for reading. If the cursor position is
1476 changed via `io-skip` or `io-pos!`, the behavior is undefined.»
1477 :doc-group io
1478 :doc-see io-line
1479 :doc-see io-column!)
1480
1481(defdoc (io-column! io new-column-number)
1482 «Change the current column number of the IO object.»
1483 :doc-group io
1484 :doc-see io-column
1485 :doc-see io-line!)
1486
1487(defdoc (io-pos io)
1488 «Return the current absolute position within the IO object in bytes.»
1489 :doc-example
1490 «(def f (buffer))
1491 (io-write f "hello, world!")
1492 (io-pos f)
1493 ; ↳ 13»
1494 :doc-group io
1495 :doc-see io-pos!)
1496
1497(defdoc (io-pos! io new-position)
1498 «Change the current absolute position within the IO object in bytes,
1499 return the resulting position.»
1500 :doc-example
1501 «(def f (buffer))
1502 (io-write f "hello, world!")
1503 (io-pos! f 64)
1504 ; ↳ 13
1505 (io-pos! f 7)
1506 ; ↳ 7
1507 (read f)
1508 ; ↳ world!»
1509 :doc-group io
1510 :doc-see io-pos
1511 :doc-see io-skip)
1512
1513(defdoc (io-close io)
1514 «Close the IO object.
1515
1516 No further operations on the IO object are possible, those will throw
1517 an exception if attempted. The only exception is `(io-filename io)`,
1518 which might be useful in some cases for debugging purposes.»
1519 :doc-example
1520 «(def f (file "/dev/random"))
1521 (io-read f 'u8)
1522 ; ↳ #u8(123)
1523 (io-close f)
1524 (io-read f 'u8)
1525 ; ‼ I/O error: closed file»
1526 :doc-group io
1527 :doc-see file)
1528
1529(defdoc (io-skip io offset (:end NIL))
1530 «Update the current absolute position within the IO object by the
1531 relative offset in bytes, return the resulting absolute position.
1532
1533 To specify the position relative to the end of the file, use the
1534 optional `:end T` argument with a negative offset.»
1535 :doc-example
1536 «(def f (buffer))
1537 (io-write f "hello, world!")
1538 (io-skip f -6 :end T)
1539 ; ↳ 7
1540 (read f)
1541 ; ↳ world!»
1542 :doc-group io
1543 :doc-see io-pos!)
1544
1545(defdoc (io-write io v (endian +endianness+))
1546 «Write the value to the IO object, return the number of bytes written.
1547
1548 The value may be a string, a fixed-width number or pointer, a rune
1549 or an array.
1550
1551 Numerical values may be written in a specific endianness order by
1552 setting `endian` to either `:little-endian` or `:big-endian`. Host
1553 CPU endianness is used if not specified.
1554
1555 When writing a rune or an array of runes, they will be converted and
1556 written as an UTF-8 string.»
1557 :doc-example
1558 «(io-write *stdout* "hello")
1559 ; ‼ hello
1560 ; ↳ 5»
1561 :doc-example
1562 «(io-write *stdout* (u32 #x44434241) :little-endian)
1563 ; ‼ ABCD
1564 ; ↳ 4»
1565 :doc-example
1566 «(io-write *stdout* #\λ)
1567 ; ‼ λ
1568 ; ↳ 2»
1569 :doc-example
1570 «(io-write *stdout* (arr 'rune #\λ #\= #\l #\a #\m #\b #\d #\a))
1571 ; ‼ λ=lambda
1572 ; ↳ 9»
1573 :doc-group io
1574 :doc-see io-read)
1575
1576(defdoc (io-read io type (endian +endianness+)))
1577
1578(defdoc (io-read io type (n NIL) (endian +endianness+))
1579 «Return a value of the specified type by reading it from the IO
1580 object.
1581
1582 The `type` must specify a fixed-width number, pointer or rune.
1583
1584 Numerical values may be read in a specific endianness order by setting
1585 `endian` to either `:little-endian` or `:big-endian`. Host CPU
1586 endianness is used if not specified.
1587
1588 If the parameter `n` is provided, read `n` values of the type,
1589 returning an array of the values or a string when `type` is `utf8`.»
1590 :doc-example
1591 «(io-read f 'utf8 5)
1592 ; ↳ "hello"»
1593 :doc-example
1594 «(io-read f 'u32)
1595 ; ↳ 57»
1596 :doc-example
1597 «(io-read f 'u32 3)
1598 ; ↳ #arr(u32 0 1 2)»
1599 :doc-example
1600 «(io-read f 'rune 6)
1601 ; ↳ #arr(rune #\λ #\a #\m #\b #\d #\a)»
1602 :doc-group io
1603 :doc-see io-write
1604 :doc-see io-read-until)
1605
1606(defdoc (io-peek io type (endian +endianness+)))
1607
1608(defdoc (io-peek io type (n NIL) (endian +endianness+))
1609 «Return a value of the specified type by peeking at data of the IO
1610 object.
1611
1612 Compared to `io-read`, this function does not consume the data -
1613 multiple repeated calls with the same arguments will return the
1614 same result.
1615
1616 The `type` must specify a fixed-width number, pointer or rune.
1617
1618 Numerical values may be peeked at in a specific endianness order
1619 by setting `endian` to either `:little-endian` or `:big-endian`.
1620 Host CPU endianness is used if not specified.
1621
1622 If the parameter `n` is provided, peek `n` values of the type,
1623 returning an array of the values or a string when `type` is `utf8`.»
1624 :doc-example
1625 «(io-peek f 'utf8 5)
1626 ; ↳ "hello"»
1627 :doc-example
1628 «(io-peek f 'u32)
1629 ; ↳ 57»
1630 :doc-example
1631 «(io-peek f 'u32 3)
1632 ; ↳ #arr(u32 0 1 2)»
1633 :doc-example
1634 «(io-peek f 'rune 6)
1635 ; ↳ #arr(rune #\λ #\a #\m #\b #\d #\a)»
1636 :doc-group io
1637 :doc-see io-read)
1638
1639(defdoc (io-read-until io r)
1640 «Return a string by reading from the IO object until encountering the
1641 delimiting rune `r`. The returned string includes the delimiter.»
1642 :doc-group io
1643 :doc-see io-read)
1644
1645(defdoc (io-copy-until io-dest io-src r)
1646 «Copy bytes from the source IO object to the destination until
1647 encountering the delimiting rune `r` and return the number of bytes
1648 copied. The copied bytes include the delimiter.»
1649 :doc-group io
1650 :doc-see io-copy)
1651
1652(defdoc (io-copy io-dest io-src (n NIL))
1653 «Copy bytes from the source IO object to the destination and return
1654 the number of bytes copied. If `n` is provided, copy up to that many
1655 bytes.»
1656 :doc-group io
1657 :doc-see io-copy-until)
1658
1659(defdoc (io-buffer-mode io)
1660 «Return the output buffering mode of the writable IO.
1661
1662 Possible values include:
1663
1664 * `NIL` - no buffering, data is written immediately
1665 * `:line` - data is written when `#\newline` is encountered
1666 * `:block` - data is written when the buffer is full
1667 * `:memory` - the IO is an in-memory buffer itself»
1668 :doc-group io
1669 :doc-see io-buffer-mode!)
1670
1671(defdoc (io-buffer-mode! io)
1672 «Changed the output buffering behavior of the writable IO, return the
1673 applied value.
1674
1675 See `io-buffer-mode` for supported modes.»
1676 :doc-group io
1677 :doc-see io-buffer-mode)
1678
1679(defdoc (io-discard-buffer io)
1680 «Discard the contents of the output buffer of the writable IO.»
1681 :doc-group io
1682 :doc-see io-flush
1683 :doc-see io-buffer-mode)
1684
1685(defdoc (io-flush io)
1686 «Flush the contents of the output buffer to the underlying IO.»
1687 :doc-group io
1688 :doc-see io-discard-buffer
1689 :doc-see io-buffer-mode)
1690
1691(defdoc (io-truncate io nbytes)
1692 «Truncate the underlying IO object to the specified number of bytes.»
1693 :doc-group io)
src/docs_array.sl+63−0
@@ -0,0 +1,63 @@
1
2(doc-group array
3 «Arrays and vectors.»)
4
5(defdoc (copy-vec vec)
6 «Return a copy of the vector with the same elements.
7
8 No copies of the values themselves are created, the original values
9 are reused.»
10 :doc-example
11 «(def v #vec(1 2 "three"))
12 (def q (copy-vec v))
13 (eq? v q)
14 ; ↳ NIL
15 (equal? v q)
16 ; ↳ T
17 (map eq? v q)
18 ; ↳ #(T T T)»
19 :doc-group array)
20
21(defdoc (vec-alloc length . rest)
22 «Construct a vector of the specified `length` by repeating
23 the elements in `rest`.»
24 :doc-example
25 «(vec-alloc 5 2.5)
26 ; ↳ #(2.5 2.5 2.5 2.5 2.5)»
27 :doc-example
28 «(vec-alloc 10 1 2.5 "a" 'b)
29 ; ↳ #(1 2.5 "a" b 1 2.5 "a" b 1 2.5)»
30 :doc-group array
31 :doc-see vec
32 :doc-see arr-alloc)
33
34(defdoc (arr type . rest)
35 «Construct a packed array containing the specified arguments.
36
37 The arguments will be coerced to a single `type` which must be
38 a fixed-width number or pointer type, or rune.»
39 :doc-example
40 «(arr 's8 0 1 2)
41 ; ↳ #arr(s8 0 1 2)»
42 :doc-example
43 «(arr 'rune 0 1 2)
44 ; ↳ #arr(rune #\nul #\soh #\stx)»
45 :doc-group array
46 :doc-see arr-alloc
47 :doc-see vec)
48
49(defdoc (arr-alloc type length . rest)
50 «Construct a packed array of the specified `length` by repeating
51 the elements in `rest`.
52
53 The arguments will be coerced to a single `type` which must be
54 a fixed-width number or pointer type, or rune.»
55 :doc-example
56 «(arr-alloc 'u16 5 -1)
57 ; ↳ #arr(u16 65535 65535 65535 65535 65535)»
58 :doc-example
59 «(arr-alloc 's8 10 0 1 2)
60 ; ↳ #arr(s8 0 1 2 0 1 2 0 1 2 0)»
61 :doc-group array
62 :doc-see arr
63 :doc-see vec-alloc)
src/docs_compress.sl+21−0
@@ -0,0 +1,21 @@
1(doc-group compress
2 «Compression.»)
3
4(defdoc (lz-pack data (level 0))
5 «Return data compressed using Lempel-Ziv.
6
7 The data must be an array, returned value will have the same type.
8 The optional `level` is between `0` and `10`. With `level` set to
9 `0` a simple LZSS using hashing will be performed. Levels between
10 `1` and `9` offer a trade-off between time/space and ratio. Level
11 `10` is optimal but very slow.»
12 :doc-group compress)
13
14(defdoc (lz-unpack data :to destination))
15(defdoc (lz-unpack data :size decompressed-bytes)
16 «Return decompressed data previously compressed using lz-pack.
17
18 Either destination for the decompressed data or the expected size of
19 the decompressed data must be specified. In the latter case a new
20 array is allocated.»
21 :doc-group compress)
src/docs_debug.sl+7−0
@@ -0,0 +1,7 @@
1(doc-group debug
2 «Debugging utilities.»)
3
4(defdoc (stacktrace)
5 «Return the current stack trace.»
6 :doc-group debug
7 :doc-see print-stack-trace)
src/docs_io.sl+434−0
@@ -0,0 +1,434 @@
1(doc-group io
2 «Files and I/O functionality.»)
3
4(defdoc *print-width*
5 «Current maximal visible width (in terminal cells) of strings printed or `NIL`
6 if strings are to be printed in full.
7
8 Truncation does not occur in the middle of a codepoint or a grapheme cluster.
9
10 Note: if a string contains an invalid rune or a control character for which
11 its width is undefined, the string is printed in full if the rune in question
12 would fit otherwise.»
13 :doc-example
14 «(with-bindings ((*print-width* 3)) (princ "abcde"))
15 ; ‼ abc...»
16 :doc-example
17 «(with-bindings ((*print-width* 3)) (princ "ab𲎿"))
18 ; ‼ ab...»
19 :doc-group io
20 :doc-see princ)
21
22(defdoc *stderr*
23 «Standard error output IO stream.»
24 :doc-group io
25 :doc-see *stdout*
26 :doc-see *stdin*)
27
28(defdoc *io-err*
29 «Current (default) error output IO stream.
30
31 Functions may use `*io-err*` for error output, which then can be
32 redirected to a different IO using `with-bindings`.»
33 :doc-group io
34 :doc-see *io-out*
35 :doc-see *io-in*
36 :doc-see with-bindings)
37
38(defdoc *stdout*
39 «Standard output IO stream.»
40 :doc-group io
41 :doc-see *stderr*
42 :doc-see *stdin*)
43
44(defdoc *io-out*
45 «Current (default) output IO stream.
46
47 Functions may use `*io-out*` for output, which then can be redirected
48 to a different IO using either `with-output-to` or (a more general)
49 `with-bindings`.»
50 :doc-group io
51 :doc-see *io-err*
52 :doc-see *io-in*
53 :doc-see with-output-to)
54
55(defdoc *stdin*
56 «Standard input IO stream.»
57 :doc-group io
58 :doc-see *stdout*
59 :doc-see *stderr*)
60
61(defdoc *io-in*
62 «Current (default) input IO stream.
63
64 Functions may use `*io-in*` for input, which then can be redirected
65 from a different IO using either `with-input-from` or (a more general)
66 `with-bindings`.»
67 :doc-group io
68 :doc-see *io-out*
69 :doc-see *io-err*
70 :doc-see with-input-from)
71
72(defdoc (path-delete path)
73 «Delete the name from the filesystem.
74
75 Throws an IO error if the path does not exist or it failed to be
76 removed.»
77 :doc-group io
78 :doc-see path-exists?
79 :doc-see path-rename)
80
81(defdoc (path-rename old new)
82 «Rename a file or a directory.
83
84 Throws an IO error if the path does not exist or it failed to be
85 rename. On most operating systems (not Plan 9), files can be moved
86 between directories.»
87 :doc-group io
88 :doc-see path-delete
89 :doc-see path-exists?)
90
91(defdoc (path-exists? path)
92 «Return `T` if `path` exists on the filesystem, `NIL` otherwise.»
93 :doc-group io
94 :doc-see file
95 :doc-see path-delete)
96
97(defdoc (path-cwd (to NIL))
98 «Return the full path to the current directory of the process, or
99 change it to the path specified with `to` argument.»
100 :doc-group io
101 :doc-see path-exists?)
102
103(defdoc (file path (mode #o644)
104 (:read NIL)
105 (:write NIL)
106 (:create NIL)
107 (:truncate NIL)
108 (:append NIL))
109 «Open a file for I/O.
110
111 An `io` object is returned. Without any modes specified the file
112 must already exist and is opened in read-only mode.
113
114 Files are created with the default mode bits #o644.»
115 :doc-group io)
116
117(defdoc (io? term)
118 «Return `T` if `term` is of `io` type, `NIL` otherwise.»
119 :doc-group io
120 :doc-group type)
121
122(defdoc (io->str io)
123 «Return the data of the in-memory `io` buffer as a string.»
124 :doc-group io)
125
126(defdoc (io-eof? io)
127 «Return `T` if `io` is currently in the "end of file" state, `NIL`
128 otherwise.»
129 :doc-group io)
130
131(defdoc (eof? v)
132 «Return `T` if the argument is `#<eof>`, `NIL` otherwise.
133
134 This object is returned by I/O functions to signal end of file,
135 where applicable.»
136 :doc-group io
137 :doc-group type)
138
139(defdoc (buffer)
140 «Return an in-memory buffer for I/O, of `io` type.
141
142 In the first form an empty buffer for both reading and writing is returned.
143
144 A read-only buffer pointing at the underlying data of `v` is returned in
145 the second form. Optionally, the range of the data (measured in bytes)
146 available when accessing the buffer may be limited by using `:start` and/or
147 `:end` keyworded arguments.»
148 :doc-example
149 «(def b (buffer))
150 (io-write b #vu8(#x68 #x65 #x6c #x6c #x6f))
151 ; ↳ 5
152 (io->str b)
153 ; ↳ "hello"»
154 :doc-example
155 «(def b (buffer (arr 'f32 1.0 2.0 3.0 -4.0)))
156 (io-pos! b 8)
157 (io-read b 'p32 2)
158 ; ↳ #arr(p32 #x40400000 #xC0800000)»
159 :doc-group io
160 :doc-see io->str)
161
162(defdoc (buffer v (:start NIL) (:end NIL)))
163
164(defdoc (io-filename io)
165 «Return the filename of the IO object.»
166 :doc-example
167 «(def f (file "/dev/random"))
168 (io-filename f)
169 ; ↳ "/dev/random"
170 (io-close f)
171 (io-filename f) ; preserved even after it's closed
172 ; ↳ "/dev/random"»
173 :doc-example
174 «(io-filename *io-out*)
175 ; ↳ "*stdout*"»
176 :doc-group io
177 :doc-see io-filename!)
178
179(defdoc (io-filename! io new-name)
180 «Change the filename of the IO object, return the new filename.
181
182 Changing the filename does not cause any side effects. The filename
183 is purely informative and does not necessarily reflect the actual
184 path.»
185 :doc-example
186 «(def f (buffer))
187 (io-filename b)
188 ; ↳ ""
189 (io-filename! b "new name") ; change the filename
190 ; ↳ "new name"
191 (io-filename b)
192 ; ↳ "new name"»
193 :doc-group io
194 :doc-see io-filename)
195
196(defdoc (io-line io)
197 «Return the current line number of the IO object.
198
199 Line number is purely informative and is only being automatically
200 updated with the files opened for reading. If the cursor position is
201 changed via `io-skip` or `io-pos!`, the behavior is undefined.»
202 :doc-group io
203 :doc-see io-column
204 :doc-see io-line!)
205
206(defdoc (io-line! io new-line-number)
207 «Change the current line number of the IO object.»
208 :doc-group io
209 :doc-see io-line
210 :doc-see io-column!)
211
212(defdoc (io-column io)
213 «Return the current column number of the IO object.
214
215 Column number is purely informative and is only being automatically
216 updated with the files opened for reading. If the cursor position is
217 changed via `io-skip` or `io-pos!`, the behavior is undefined.»
218 :doc-group io
219 :doc-see io-line
220 :doc-see io-column!)
221
222(defdoc (io-column! io new-column-number)
223 «Change the current column number of the IO object.»
224 :doc-group io
225 :doc-see io-column
226 :doc-see io-line!)
227
228(defdoc (io-pos io)
229 «Return the current absolute position within the IO object in bytes.»
230 :doc-example
231 «(def f (buffer))
232 (io-write f "hello, world!")
233 (io-pos f)
234 ; ↳ 13»
235 :doc-group io
236 :doc-see io-pos!)
237
238(defdoc (io-pos! io new-position)
239 «Change the current absolute position within the IO object in bytes,
240 return the resulting position.»
241 :doc-example
242 «(def f (buffer))
243 (io-write f "hello, world!")
244 (io-pos! f 64)
245 ; ↳ 13
246 (io-pos! f 7)
247 ; ↳ 7
248 (read f)
249 ; ↳ world!»
250 :doc-group io
251 :doc-see io-pos
252 :doc-see io-skip)
253
254(defdoc (io-close io)
255 «Close the IO object.
256
257 No further operations on the IO object are possible, those will throw
258 an exception if attempted. The only exception is `(io-filename io)`,
259 which might be useful in some cases for debugging purposes.»
260 :doc-example
261 «(def f (file "/dev/random"))
262 (io-read f 'u8)
263 ; ↳ #u8(123)
264 (io-close f)
265 (io-read f 'u8)
266 ; ‼ I/O error: closed file»
267 :doc-group io
268 :doc-see file)
269
270(defdoc (io-skip io offset (:end NIL))
271 «Update the current absolute position within the IO object by the
272 relative offset in bytes, return the resulting absolute position.
273
274 To specify the position relative to the end of the file, use the
275 optional `:end T` argument with a negative offset.»
276 :doc-example
277 «(def f (buffer))
278 (io-write f "hello, world!")
279 (io-skip f -6 :end T)
280 ; ↳ 7
281 (read f)
282 ; ↳ world!»
283 :doc-group io
284 :doc-see io-pos!)
285
286(defdoc (io-write io v (endian +endianness+))
287 «Write the value to the IO object, return the number of bytes written.
288
289 The value may be a string, a fixed-width number or pointer, a rune
290 or an array.
291
292 Numerical values may be written in a specific endianness order by
293 setting `endian` to either `:little-endian` or `:big-endian`. Host
294 CPU endianness is used if not specified.
295
296 When writing a rune or an array of runes, they will be converted and
297 written as an UTF-8 string.»
298 :doc-example
299 «(io-write *stdout* "hello")
300 ; ‼ hello
301 ; ↳ 5»
302 :doc-example
303 «(io-write *stdout* (u32 #x44434241) :little-endian)
304 ; ‼ ABCD
305 ; ↳ 4»
306 :doc-example
307 «(io-write *stdout* #\λ)
308 ; ‼ λ
309 ; ↳ 2»
310 :doc-example
311 «(io-write *stdout* (arr 'rune #\λ #\= #\l #\a #\m #\b #\d #\a))
312 ; ‼ λ=lambda
313 ; ↳ 9»
314 :doc-group io
315 :doc-see io-read)
316
317(defdoc (io-read io type (endian +endianness+)))
318
319(defdoc (io-read io type (n NIL) (endian +endianness+))
320 «Return a value of the specified type by reading it from the IO
321 object.
322
323 The `type` must specify a fixed-width number, pointer or rune.
324
325 Numerical values may be read in a specific endianness order by setting
326 `endian` to either `:little-endian` or `:big-endian`. Host CPU
327 endianness is used if not specified.
328
329 If the parameter `n` is provided, read `n` values of the type,
330 returning an array of the values or a string when `type` is `utf8`.»
331 :doc-example
332 «(io-read f 'utf8 5)
333 ; ↳ "hello"»
334 :doc-example
335 «(io-read f 'u32)
336 ; ↳ 57»
337 :doc-example
338 «(io-read f 'u32 3)
339 ; ↳ #arr(u32 0 1 2)»
340 :doc-example
341 «(io-read f 'rune 6)
342 ; ↳ #arr(rune #\λ #\a #\m #\b #\d #\a)»
343 :doc-group io
344 :doc-see io-write
345 :doc-see io-read-until)
346
347(defdoc (io-peek io type (endian +endianness+)))
348
349(defdoc (io-peek io type (n NIL) (endian +endianness+))
350 «Return a value of the specified type by peeking at data of the IO
351 object.
352
353 Compared to `io-read`, this function does not consume the data -
354 multiple repeated calls with the same arguments will return the
355 same result.
356
357 The `type` must specify a fixed-width number, pointer or rune.
358
359 Numerical values may be peeked at in a specific endianness order
360 by setting `endian` to either `:little-endian` or `:big-endian`.
361 Host CPU endianness is used if not specified.
362
363 If the parameter `n` is provided, peek `n` values of the type,
364 returning an array of the values or a string when `type` is `utf8`.»
365 :doc-example
366 «(io-peek f 'utf8 5)
367 ; ↳ "hello"»
368 :doc-example
369 «(io-peek f 'u32)
370 ; ↳ 57»
371 :doc-example
372 «(io-peek f 'u32 3)
373 ; ↳ #arr(u32 0 1 2)»
374 :doc-example
375 «(io-peek f 'rune 6)
376 ; ↳ #arr(rune #\λ #\a #\m #\b #\d #\a)»
377 :doc-group io
378 :doc-see io-read)
379
380(defdoc (io-read-until io r)
381 «Return a string by reading from the IO object until encountering the
382 delimiting rune `r`. The returned string includes the delimiter.»
383 :doc-group io
384 :doc-see io-read)
385
386(defdoc (io-copy-until io-dest io-src r)
387 «Copy bytes from the source IO object to the destination until
388 encountering the delimiting rune `r` and return the number of bytes
389 copied. The copied bytes include the delimiter.»
390 :doc-group io
391 :doc-see io-copy)
392
393(defdoc (io-copy io-dest io-src (n NIL))
394 «Copy bytes from the source IO object to the destination and return
395 the number of bytes copied. If `n` is provided, copy up to that many
396 bytes.»
397 :doc-group io
398 :doc-see io-copy-until)
399
400(defdoc (io-buffer-mode io)
401 «Return the output buffering mode of the writable IO.
402
403 Possible values include:
404
405 * `NIL` - no buffering, data is written immediately
406 * `:line` - data is written when `#\newline` is encountered
407 * `:block` - data is written when the buffer is full
408 * `:memory` - the IO is an in-memory buffer itself»
409 :doc-group io
410 :doc-see io-buffer-mode!)
411
412(defdoc (io-buffer-mode! io)
413 «Changed the output buffering behavior of the writable IO, return the
414 applied value.
415
416 See `io-buffer-mode` for supported modes.»
417 :doc-group io
418 :doc-see io-buffer-mode)
419
420(defdoc (io-discard-buffer io)
421 «Discard the contents of the output buffer of the writable IO.»
422 :doc-group io
423 :doc-see io-flush
424 :doc-see io-buffer-mode)
425
426(defdoc (io-flush io)
427 «Flush the contents of the output buffer to the underlying IO.»
428 :doc-group io
429 :doc-see io-discard-buffer
430 :doc-see io-buffer-mode)
431
432(defdoc (io-truncate io nbytes)
433 «Truncate the underlying IO object to the specified number of bytes.»
434 :doc-group io)
src/docs_list.sl+68−0
@@ -0,0 +1,68 @@
1(doc-group list
2 «Working with lists.»)
3
4(defdoc NIL
5 «An empty list. Can be used as the opposite of T in boolean
6 expressions.»
7 :doc-example
8 «(not NIL)
9 ; ↳ T»
10 :doc-example
11 «(if NIL 'yes 'no)
12 ; ↳ no»
13 :doc-example
14 «(car NIL)
15 ; ↳ NIL»
16 :doc-example
17 «(cdr NIL)
18 ; ↳ NIL»
19 :doc-group list
20 :doc-see T)
21
22(defdoc (length seq)
23 «Return the length of the sequence.
24
25 String's length is measured in UTF-8 codepoints. For tables the number
26 of key-value pairs is returned.
27
28 Note: for circular lists the result is `NIL`. A type error exception is
29 thrown on improper lists, which are not considered valid sequences.»
30 :doc-example
31 «(length "абвгд")
32 ; ↳ 5»
33 :doc-example
34 «(length #(abc 123))
35 ; ↳ 2»
36 :doc-example
37 «(length #table(0 a 1 b 2 c))
38 ; ↳ 3»
39 :doc-example
40 «(length (arr 'u32 1 2 3 4))
41 ; ↳ 4»
42 :doc-example
43 «(length '(1 2 3 4 5))
44 ; ↳ 5»
45 :doc-example
46 «(length '(1 2 3 4 . 5)) ; improper list
47 ; ‼ type error: expected cons, got fixnum: 5»
48 :doc-example
49 «(length '#0=(1 . #0#)) ; circular list
50 ; ↳ NIL»
51 :doc-group array
52 :doc-group list
53 :doc-group table
54 :doc-see proper-list?)
55
56(defdoc (assq key lst)
57 «Return a pair of a matching key and the associated value, or `NIL` if
58 none matched. Keys are compared using `eq?`.»
59 :doc-group list
60 :doc-see assoc
61 :doc-see assv)
62
63(defdoc (memq item lst)
64 «Return the tail of a list beginning with the item, or `NIL` otherwise.
65 List elements are compared to the `item` using `eq?`.»
66 :doc-group list
67 :doc-see member
68 :doc-see memv)
src/docs_misc.sl+90−0
@@ -0,0 +1,90 @@
1(doc-group misc
2 «Miscellaneous.»)
3
4(defdoc T
5 «A boolean "true".»
6 :doc-example
7 «(not T)
8 ; ↳ NIL»
9 :doc-example
10 «(if T 'yes 'no)
11 ; ↳ yes»
12 :doc-group misc
13 :doc-see NIL)
14
15(defdoc (sym term . rest)
16 «Return a symbol with the name being the concatenation of terms
17 formatted as strings.
18
19 This is equivalent to `(sym (str …))`.»
20 :doc-example
21 «(sym "a" 'b 1)
22 ; ↳ ab1»
23 :doc-group misc
24 :doc-see sym?)
25
26(defdoc (set-top-level-value! sym expr)
27 «Evaluate the expression and assign the result to the symbol in the top
28 level (global) environment.
29
30 The use of this function is discouraged. For the usual assignment of
31 values to names it is recommended instead to use `(def …)` and/or
32 `(set! …)`.»
33 :doc-example
34 «(let {[abc 2]}
35 (set-top-level-value! 'abc 123)
36 abc)
37 ; ↳ 2
38 abc
39 ; ↳ 123»
40 :doc-group misc
41 :doc-see top-level-value
42 :doc-see set!)
43
44(defdoc (top-level-value sym)
45 «Return the value bound to the symbol in the top level (global)
46 environment.»
47 :doc-example
48 «(def abc 1)
49 (let {[abc 2]}
50 (cons abc (top-level-value 'abc)))
51 ; ↳ (2 . 1)
52 abc
53 ; ↳ 1»
54 :doc-group misc
55 :doc-see set-top-level-value!)
56
57(defdoc (makunbound sym)
58 «Make the symbol unbound.»
59 :doc-example
60 «(def x 1)
61 (bound? 'x)
62 ; ↳ T
63 x
64 ; ↳ 1
65 (makunbound 'x)
66 (bound? 'x)
67 ; ↳ NIL
68 x
69 ; ‼ eval: variable x has no value»
70 :doc-group misc
71 :doc-see bound?)
72
73(defdoc (size-of v)
74 «Return the size of the value in bytes, if applicable.
75
76 Works only with C integer types, arrays, strings and in-memory
77 buffers.»
78 :doc-example
79 «(size-of "hello")
80 ; ↳ 5»
81 :doc-example
82 «(size-of (arr 'u32 1 2 3))
83 ; ↳ 12»
84 :doc-example
85 «(def b (buffer))
86 (io-write b "hello")
87 (size-of b)
88 ; ↳ 5»
89 :doc-group misc
90 :doc-see type-of)
src/docs_number.sl+323−0
@@ -0,0 +1,323 @@
1(doc-group number
2 «Operations on numbers, mathematical constants.»)
3
4(defdoc +most-positive-fixnum+
5 «A constant integer closest to positive infinity that can be
6 represented by fixnum type on this particular platform.»
7 :doc-group number
8 :doc-see +most-negative-fixnum+)
9
10(defdoc +most-negative-fixnum+
11 «A constant integer closest to negative infinity that can be
12 represented by fixnum type on this particular platform.»
13 :doc-group number
14 :doc-see +most-positive-fixnum+)
15
16(defdoc +f32-epsilon+
17 «A smallest positive floating point number such that
18 `(+ 1.0f +f32-epsilon+)` is not equal to `1.0f`.»
19 :doc-group number
20 :doc-see +f64-epsilon)
21
22(defdoc +f64-epsilon+
23 «A smallest positive floating point number such that
24 `(+ 1.0 +f64-epsilon+)` is not equal to `1.0`.»
25 :doc-group number
26 :doc-see +f32-epsilon)
27
28(defdoc (fixnum (n 0))
29 «Construct a fixnum.»
30 :doc-group number
31 :doc-see fixnum?)
32
33(defdoc (u8 (n 0))
34 «Construct a 8-bit unsigned number.»
35 :doc-group number
36 :doc-see s8)
37
38(defdoc (s8 (n 0))
39 «Construct a 8-bit signed number.»
40 :doc-group number
41 :doc-see u8)
42
43(defdoc (u16 (n 0))
44 «Construct a 16-bit unsigned number.»
45 :doc-group number
46 :doc-see s16)
47
48(defdoc (s16 (n 0))
49 «Construct a 16-bit signed number.»
50 :doc-group number
51 :doc-see u16)
52
53(defdoc (u32 (n 0))
54 «Construct a 32-bit unsigned number.»
55 :doc-group number
56 :doc-see s32)
57
58(defdoc (s32 (n 0))
59 «Construct a 32-bit signed number.»
60 :doc-group number
61 :doc-see u32)
62
63(defdoc (u64 (n 0))
64 «Construct a 64-bit unsigned number.»
65 :doc-group number
66 :doc-see s64)
67
68(defdoc (s64 (n 0))
69 «Construct a 64-bit signed number.»
70 :doc-group number
71 :doc-see u64)
72
73(defdoc (f32 (n 0.0))
74 «Construct a 32-bit floating point number.»
75 :doc-group number
76 :doc-see f64)
77
78(defdoc (f64 (n 0.0))
79 «Construct a 64-bit floating point number.»
80 :doc-group number
81 :doc-see f32)
82
83(defdoc (p32 (n 0))
84 «Construct a 32-bit abstract pointer value.»
85 :doc-group number
86 :doc-see p64
87 :doc-see ptr)
88
89(defdoc (p64 (n 0))
90 «Construct a 64-bit abstract pointer value.»
91 :doc-group number
92 :doc-see p32
93 :doc-see ptr)
94
95(defdoc (ptr (n 0))
96 «Construct an abstract pointer value. The bit width is either 32-bit
97 or 64-bit, depending on the platform the code is executing on.
98
99 Note: certain arithmetic operations on pointers, such as division and
100 multiplication, will throw an error. This is done on purpose since
101 doing that on pointers rarely makes sense.»
102 :doc-group number
103 :doc-see p32
104 :doc-see p64
105 :doc-see ptr?)
106
107(defdoc (bignum (n 0))
108 «Construct a bignum. As opposed to a fixnum, its value is not limited.»
109 :doc-group number
110 :doc-see bignum?)
111
112(defdoc (floor x)
113 «Return the largest integer that is less than or equal to `x`.
114
115 Infinity and NaN `floor` to themselves.»
116 :doc-example
117 «(floor 1.2)
118 ; ↳ 1.0»
119 :doc-example
120 «(floor -1.2)
121 ; ↳ -2.0»
122 :doc-example
123 «(floor -5)
124 ; ↳ -5.0»
125 :doc-group number
126 :doc-see ceiling)
127
128(defdoc (ceiling x)
129 «Return the smallest integer that is greater than or equal to `x`.
130
131 Infinity and NaN `ceiling` to themselves.»
132 :doc-example
133 «(ceiling 1.2)
134 ; ↳ 2.0»
135 :doc-example
136 «(ceiling -1.2)
137 ; ↳ -1.0»
138 :doc-example
139 «(ceiling -5)
140 ; ↳ -5.0»
141 :doc-group number
142 :doc-see floor)
143
144(defdoc (ash int nbits)
145 «Return the integer shifted by the specified number of bits to the
146 right (negative `nbits`) or left (positive `nbits`).»
147 :doc-example
148 «(ash -3 3)
149 ; ↳ -24»
150 :doc-example
151 «(ash 1 3)
152 ; ↳ 8»
153 :doc-group number)
154
155(defdoc (lognot int)
156 «Return the result of bitwise NOT (complement) operation on an integer.»
157 :doc-example
158 «(lognot 0)
159 ; ↳ -1»
160 :doc-example
161 «(lognot #s8(63))
162 ; ↳ #s8(-64)»
163 :doc-example
164 «(lognot #u16(32767))
165 ; ↳ #u16(32768)»
166 :doc-group number)
167
168(defdoc (logior . ints)
169 «Return the result of bitwise OR (inclusive OR) operation on integers.»
170 :doc-example
171 «(logior)
172 ; ↳ 0»
173 :doc-example
174 «(logior 2)
175 ; ↳ 2»
176 :doc-example
177 «(logior 2 3)
178 ; ↳ 3»
179 :doc-example
180 «(logior 2 3 4)
181 ; ↳ 7»
182 :doc-group number)
183
184(defdoc (logand . ints)
185 «Return the result of bitwise AND operation on integers.»
186 :doc-example
187 «(logand)
188 ; ↳ 0»
189 :doc-example
190 «(logand 2)
191 ; ↳ 2»
192 :doc-example
193 «(logand 2 3)
194 ; ↳ 2»
195 :doc-example
196 «(logand 2 3 4)
197 ; ↳ 0»
198 :doc-group number)
199
200(defdoc (logxor . ints)
201 «Return the result of bitwise XOR (exclusive OR) operation on integers.»
202 :doc-example
203 «(logxor)
204 ; ↳ 0»
205 :doc-example
206 «(logxor 2)
207 ; ↳ 2»
208 :doc-example
209 «(logxor 2 3)
210 ; ↳ 1»
211 :doc-example
212 «(logxor 2 3 4)
213 ; ↳ 5»
214 :doc-group number)
215
216(defdoc +pi+
217 «Mathematical constant π.»
218 :doc-group number)
219
220(defdoc (acos x)
221 «Return the arc cosine of `x` in radians.»
222 :doc-group number)
223
224(defdoc (asin x)
225 «Return the arc sine of `x` in radians.»
226 :doc-group number)
227
228(defdoc (atan x)
229 «Return the arc tangent of `x` in radians.»
230 :doc-group number)
231
232(defdoc (atan y x)
233 «Return the arc tangent of `y/x` in radians.»
234 :doc-group number)
235
236(defdoc (cos r)
237 «Return the cosine of `r`, where `r` is given in radians.»
238 :doc-group number)
239
240(defdoc (sin r)
241 «Return the sine of `r`, where `r` is given in radians.»
242 :doc-group number)
243
244(defdoc (tan r)
245 «Return the tangent of `r`, where `r` is given in radians.»
246 :doc-group number)
247
248(defdoc (cosh x)
249 «Return the hyperbolic cosine of `x`.»
250 :doc-group number)
251
252(defdoc (sinh r)
253 «Return the hyperbolic sine of `x`.»
254 :doc-group number)
255
256(defdoc (tanh r)
257 «Return the hyperbolic tangent of `x`.»
258 :doc-group number)
259
260(defdoc (sqrt x)
261 «Return the square root of `x`.»
262 :doc-example
263 «(sqrt 9.0)
264 ; ↳ 3.0»
265 :doc-group number)
266
267(defdoc (exp p)
268 «Return the exponential - value of `e` (natural logarithms base) raised
269 to the power of `p`.»
270 :doc-example
271 «(exp 1)
272 ; ↳ 2.71828… ; e»
273 :doc-group number)
274
275(defdoc (expt x p)
276 «Return the value of `x` raised to the power of `p`.»
277 :doc-example
278 «(expt 3 3) ; cube of 3
279 ; ↳ 27»
280 :doc-example
281 «(expt 27 (/ 1 3)) ; cube root of 27
282 ; ↳ 3»
283 :doc-group number)
284
285(defdoc (log x (base (exp 1)))
286 «Return the logarithm of `x` in `base`.
287
288 Default base is `e`, returning natural logarithm of the first
289 argument.»
290 :doc-example
291 «(log 100 10)
292 ; ↳ 2.0»
293 :doc-example
294 «(log 256 2)
295 ; ↳ 8.0»
296 :doc-example
297 «(log (exp 4))
298 ; ↳ 4.0»
299 :doc-group number)
300
301(defdoc (truncate x)
302 «Return the integer value of `x` rounded toward zero.
303
304 If `x` is already an integer (or infinite, or NaN), result is `x`.»
305 :doc-example
306 «(truncate -123.45)
307 ; ↳ -123»
308 :doc-example
309 «(truncate 299.9)
310 ; ↳ 299»
311 :doc-group number)
312
313(defdoc (int-valued? x)
314 «Return `T` if `x` is a number and is equal (as in `=`) to an
315 integer value of `x`.»
316 :doc-example
317 «(int-valued? -123.0)
318 ; ↳ T»
319 :doc-example
320 «(int-valued? -123.1)
321 ; ↳ NIL»
322 :doc-group number
323 :doc-see int?)
src/docs_random.sl+60−0
@@ -0,0 +1,60 @@
1(doc-group random
2 «Random numbers generation.»)
3
4(defdoc *random-state*
5 «The random state of the current process.
6
7 The state isn't set (is `NIL`) until a call is made to any function
8 that uses it.»
9 :doc-group random
10 :doc-see make-random-state
11 :doc-see random-state?)
12
13(defdoc (make-random-state (state NIL))
14 «Return a new random state.
15
16 If `state` is `NIL`, a copy of the random state of the current process
17 (`*random-state*`) is returned. If `state` is `T`, the returned random
18 state is a new one that has been randomly initialized. If an already
19 existing random state is passed, the returned value is a copy of that
20 state.»
21 :doc-group random
22 :doc-see *random-state*
23 :doc-see random-state?
24 :doc-see random)
25
26(defdoc (random-state? state)
27 «Return `T` if the argument is a random state object, `NIL` otherwise.»
28 :doc-example
29 «(random-state? 1)
30 ; ↳ NIL»
31 :doc-example
32 «(random-state? (make-random-state))
33 ; ↳ T»
34 :doc-example
35 «(random-state? *random-state*)
36 ; ↳ T»
37 :doc-group random
38 :doc-see *random-state*
39 :doc-see make-random-state)
40
41(defdoc (random max (state NIL))
42 «Return a random number in the range `[0, max]` (inclusive).
43
44 The result is either an integer or a floating point number, depending
45 on the type of the `max` argument, which has to be a positive number.
46
47 Optional `state` can be specified, otherwise the random state of the
48 current process (`*random-state*`) is used. State will be modified
49 in-place.»
50 :doc-example
51 «(random 1)
52 ; ↳ 1»
53 :doc-example
54 «(random 10000000000000000000000000000000000)
55 ; ↳ 5312781302474765749507273681609477»
56 :doc-example
57 «(random 1.0)
58 ; ↳ 0.69517»
59 :doc-group random
60 :doc-see make-random-state)
src/docs_seq.sl+0−0

Empty file added.

src/docs_string.sl+117−0
@@ -0,0 +1,117 @@
1(doc-group string
2 «Strings and runes.»)
3
4(defdoc (rune (n #xfffd))
5 «Construct a rune from a Unicode code point. Without code point
6 specified, an "invalid" rune is returned.»
7 :doc-group string
8 :doc-see rune?)
9
10(defdoc (str . terms)
11 «Return concatenation of terms formatted as strings.
12
13 This is equivalent to `(princ terms…)`, except the string is
14 _returned_, rather than printed.»
15 :doc-example
16 «(str "a" 'b 1 #(0))
17 ; ↳ "ab1#(0)"»
18 :doc-group string)
19
20(defdoc (str-width s)
21 «Return the number of columns needed to represent a string or a rune.
22
23 If a non-printable control rune is encountered, the result is `NIL`,
24 else it is a non-negative integer. Rune `#\null` is considered of width zero.»
25 :doc-example
26 «(str-width #\й)
27 ; ↳ 1»
28 :doc-example
29 «(str-width "⌛!")
30 ; ↳ 3»
31 :doc-example
32 «(str-width "nope\n")
33 ; ↳ NIL»
34 :doc-group string)
35
36(defdoc (str-rune s n)
37 «Return the nth rune of the string.
38
39 Throws an exception if the index `n` is out of bounds.»
40 :doc-example
41 «(str-rune "йцукен" 3)
42 ; ↳ #\к»
43 :doc-group string
44 :doc-see str-sub)
45
46(defdoc (str-sub s start (end NIL))
47 «Return the portion of the string within the specified bounds.
48
49 The `start` and `end` index by rune. Specifying any index out of bounds
50 of the string will result in an exception thrown.
51
52 If `end` isn't specified the portion is assumed to begin at `start`
53 until the end of the original string.»
54 :doc-example
55 «(str-sub "hello" 2)
56 ; ↳ "llo"»
57 :doc-example
58 «(str-sub "hello" 3 3)
59 ; ↳ ""»
60 :doc-example
61 «(str-sub "hello" 2 4)
62 ; ↳ "ll"»
63 :doc-group string
64 :doc-see str-rune)
65
66(defdoc (str-utf8? s)
67 «Return `T` if `s` is a valid UTF-8 string, `NIL` otherwise.»
68 :doc-example
69 «(str-utf8? "привет")
70 ; ↳ T»
71 :doc-example
72 «(str-utf8? "при\xffвет")
73 ; ↳ NIL»
74 :doc-group string
75 :doc-see str?)
76
77(defdoc (str->num s (:base NIL))
78 «Return the number using the radix `base` in the string `s`.
79
80 Returns `NIL` if the number could not be parsed. Any number of leading
81 and/or trailing whitespace runes is allowed and those will be ignored.»
82 :doc-example
83 «(str->num "1.2")
84 ; ↳ 1.2»
85 :doc-example
86 «(str->num "#x123")
87 ; ↳ 291»
88 :doc-example
89 «(str->num "ffff" :base 16)
90 ; ↳ 65535»
91 :doc-example
92 «(str->num "777" :base 8)
93 ; ↳ 511»
94 :doc-group string
95 :doc-see num->str)
96
97(defdoc (str-split str (sep " \n\t\v\f") (:trim NIL))
98 «Return a list of substrings of `str` by splitting at any character in
99 the string `sep`. The splitting characters are removed.
100
101 By default the string is split on space, line feed (newline),
102 horizontal and vertical tab, and form feed.
103
104 Trim removes empty strings from the list.»
105 :doc-example
106 «(str-split "hello world")
107 ; ↳ ("hello" "world")»
108 :doc-example
109 «(str-split "multiple spaces ")
110 ; ↳ ("multiple" "" "" "spaces" "")»
111 :doc-example
112 «(str-split "multiple spaces " :trim T)
113 ; ↳ ("multiple" "spaces")»
114 :doc-example
115 «(str-split "too many vowels" "aeiou")
116 ; ↳ ("t" "" " m" "ny v" "w" "ls")»
117 :doc-group string)
src/docs_struct.sl+69−0
@@ -0,0 +1,69 @@
1(doc-group struct
2 «Declaring and manipulating structures.»)
3
4(defdoc (defstruct name
5 docs…
6 options…
7 (slot-1 DEFAULT)
8 slot-2
9 slot-3))
10 ',sym ',doc ',callvars
11
12(defdoc (defstruct name (:type vec)
13 (:named T named-supplied)
14 (:constructor T constructor-supplied)
15 (:conc-name T conc-name-supplied)
16 (:predicate T predicate-supplied)
17 . slots)
18 «Declare a new structure type with the specified name and slots.
19
20 The default underlying type is a "named" vector (`:type vec`), where
21 the first element is the name of the structure's type, the rest are
22 the keyworded slot values. A list with slot values alone can be used
23 instead by adding `:type list` option. The list will not contain the
24 name of the struct by default, which can be enabled with `:named T`
25 option.
26
27 As an example, the following declaration generates the default
28 constructor for a structure of three slots, with one of them (`c`)
29 having a non-`NIL` default value and marked as read-only:
30
31 (defstruct blah "Return stuff." :doc-group stuff a b (c 1 :read-only T))
32 ; (make-blah (:a NIL) (:b NIL) (:c 1))
33 ; (blah-a s)
34 ; (blah-b s)
35 ; (blah-c s)
36 ; (blah-a! s new-a)
37 ; (blah-b! s new-b)
38
39 Slot's options, if any, should be specified after its default value.
40 Supported options are:
41
42 ; mark the slot as read-only
43 ; its value can be read, but trying to modify it will throw an error
44 … :read-only T
45
46 The constructor can be changed in several ways:
47
48 ; disable the constructor altogether
49 (defstruct blah :constructor NIL a b c)
50 ; only change its name
51 (defstruct blah :constructor blargh a b c)
52 ; rename AND avoid using keywords
53 (defstruct blah :constructor (blah a b c) a b c)
54
55 The option `:conc-name` specifies the slot accessor/setter prefix,
56 which defaults to `structname-`. Prefix can be disabled entirely with
57 `:conc-name NIL`.
58
59 Slot setters are generated for writable slots by appending `!`
60 (exclamation mark) to the accessor's name.
61
62 Default predicate can be disabled or its name, which defaults to
63 `structname?`, changed:
64
65 ; use "blargh?" instead of "blah?"
66 (defstruct blah :predicate blargh? a b c)
67 ; without predicate
68 (defstruct blah :predicate NIL a b c)»
69 :doc-group struct)
src/docs_sys.sl+84−0
@@ -0,0 +1,84 @@
1(doc-group sys
2 «OS-specific functions.»)
3
4(defdoc +endianness+
5 «Endianess of the CPU the VM is running on, a constant.
6
7 Set to either `:big-endian` or `:little-endian`.»
8 :doc-group sys)
9
10(defdoc *directory-separator*
11 «OS-specific path separator.
12
13 It is preferred over hardcoded `"/"`, for portability.»
14 :doc-group sys
15 :doc-see *linefeed*)
16
17(defdoc *linefeed*
18 «OS-specific _line_ _feed_ value.
19
20 It is preferred over hardcoded `"\n"`, for portability.»
21 :doc-group sys
22 :doc-see newline
23 :doc-see *directory-separator*)
24
25(defdoc +os-name+
26 «The name of the operating system this StreetLISP VM executable was
27 built for.
28
29 It's set to a lowercase string and its value is considered "best
30 effort" - it might not always be accurate.
31
32 Possible values: `"unknown"`, `"plan9"`, `"linux"`, `"openbsd"`,
33 `"netbsd"`, `"dragonflybsd"`, `"freebsd"`, `"haiku"`, `"macosx"`,
34 `"macos"`, `"dos"`.»
35 :doc-group sys
36 :doc-see +os-version+)
37
38(defdoc +os-version+
39 «The "version" of the operating system StreetLISP VM is running on.
40
41 The availability of the constant and its value depends on the
42 operating system and is only provided for the user to see. No logic
43 should depend on it.»
44 :doc-example
45 «; on Alpine Linux
46 +os-version+
47 ; ↳ "6.14.5-0-edge" ; kernel version»
48 :doc-example
49 «; on 9front
50 +os-version+
51 ; ↳ NIL ; 9front does not define one»
52 :doc-group sys
53 :doc-see +os-name+)
54
55(defdoc (os-getenv name)
56 «Return the value of the environment variable `name` or `NIL` if it's
57 not set.»
58 :doc-group sys
59 :doc-see os-setenv)
60
61(defdoc (os-setenv name value)
62 «Add or replace the value of the environment variable `name` to
63 `value`.
64
65 If `value` is `NIL`, the variable is deleted from the environment if
66 it exists.»
67 :doc-group sys
68 :doc-see os-getenv)
69
70(defdoc (exit (msg NIL) (code 0))
71 «Terminate the process with the specified message and code. Does not return.
72
73 The message is expected to be a non-empty string in case of an error.
74 The code is expected to be a positive integer in case of an error.»
75 :doc-example
76 «(exit) ; exit with code 0 (message '' on Plan 9)»
77 :doc-example
78 «(exit "error") ; exit with code 1 (message "error" on Plan 9)»
79 :doc-group sys)
80
81(defdoc (getpid)
82 «Return the process ID of the StreetLISP VM within the operating system
83 it's running on.»
84 :doc-group sys)
src/docs_table.sl+81−0
@@ -0,0 +1,81 @@
1(doc-group table
2 «Tables of keys with associated values.»)
3
4(defdoc (del! table key)
5 «Remove any existing mapping for `key` and return the table.»
6 :doc-example
7 «(def t #table(a 1 b 2))
8 (del! t 'c)
9 ; ↳ #table(b 2 a 1)
10 (del! t 'b)
11 ; ↳ #table(a 1)
12 t
13 ; ↳ #table(a 1)»
14 :doc-group table
15 :doc-see has?
16 :doc-see get
17 :doc-see put!)
18
19(defdoc (get table key [failed-result])
20 «Return the value associated with the `key` in the table.
21
22 If the key isn't in the table then either return the optional
23 `failed-result` argument or (if called without the argument) throw a
24 `key-error` exception.»
25 :doc-example
26 «(def t #table(a 1 b 2))
27 (get t 'a)
28 ; ↳ 1
29 (get t 'b NIL)
30 ; ↳ 2
31 (get t 'c)
32 ; ‼ key not found: a
33 (get t 'c 123)
34 ; ↳ 123»
35 :doc-group table
36 :doc-see has?
37 :doc-see put!
38 :doc-see del!)
39
40(defdoc (put! table key value)
41 «Store the value associated with the key and return the table.
42
43 Any existing value associated with the key will be replaced.»
44 :doc-example
45 «(def t #table(a 1 b 2))
46 (put! t 'c 3)
47 ; ↳ #table(c 3 b 2 a 1)
48 (put! t 'a "hello")
49 ; ↳ #table(c 3 b 2 a "hello")»
50 :doc-group table
51 :doc-see get
52 :doc-see has?
53 :doc-see del!)
54
55(defdoc (has? table key)
56 «Return `T` if the table has a value associated with the key, `NIL` otherwise.»
57 :doc-example
58 «(def t #table(a 1 b 2))
59 (has? t 'c)
60 ; ↳ NIL
61 (has? t 'a)
62 ; ↳ T»
63 :doc-group table
64 :doc-see get
65 :doc-see put!
66 :doc-see del!)
67
68(defdoc (table . rest)
69 «Construct a table from keys from the arguments.
70
71 Every two arguments are expected to be a key and a value associated
72 with that key.»
73 :doc-example
74 «(table)
75 ; ↳ #table()»
76 :doc-example
77 «(table 'a 1 'b 2)
78 ; ↳ #table(a 1 b 2)»
79 :doc-group table
80 :doc-see get
81 :doc-see put!)
src/docs_time.sl+55−0
@@ -0,0 +1,55 @@
1(doc-group time
2 «Measuring, manipulating and displaying time.»)
3
4(defdoc (sleep sec)
5 «Halt the StreetLISP VM for the specified duration of time in seconds.b»
6 :doc-example
7 «(sleep 0.1) ; sleep for 100ms»
8 :doc-group time)
9
10(defdoc (nanoseconds-monotonic)
11 «Return the number of nanoseconds passed since the first call to this
12 function.
13
14 The first call will always return 0.»
15 :doc-example
16 «(nanoseconds-monotonic)
17 ; ↳ #u64(0)
18 (nanoseconds-monotonic)
19 ; ↳ #u64(47840)»
20 :doc-group time
21 :doc-see time-now)
22
23(defdoc (time-now)
24 «Return the number of nanoseconds since Epoch (1970-01-01 00:00:00).
25
26 This measures the system-wide real (wall-clock) time.»
27 :doc-example
28 «(time-now)
29 ; ↳ 1746494461277334928»
30 :doc-group time
31 :doc-see nanoseconds-monotonic)
32
33(defdoc (time->str sec)
34 «Return the number of nanoseconds since Epoch formatted as time and date.
35
36 This is the opposite of `str->time`.»
37 :doc-example
38 «(time->str (time-now))
39 ; ↳ "Tue May 6 03:21:01 CES 2025"»
40 :doc-group time
41 :doc-see str->time
42 :doc-see time-now)
43
44(defdoc (str->time str)
45 «Return the number of nanoseconds since Epoch from a time and date
46 formatted as a string.
47
48 Because the supported format is limited, the returned value will have
49 precision in seconds at most.»
50 :doc-example
51 «(str->time "Tue May 6 03:21:01 CES 2025")
52 ; ↳ 1746494461»
53 :doc-group time
54 :doc-see time->str
55 :doc-see time-now)
src/docs_type.sl+78−0
@@ -0,0 +1,78 @@
1(doc-group type
2 «Dealing with types.»)
3
4(defdoc (const? term)
5 «Return `T` if the term refers to a constant, `NIL` otherwise.
6
7 Constants cannot be modified with `set!`. Trying to do so will result
8 in an exception.»
9 :doc-example
10 «(const? 12345) ; a number
11 ; ↳ T»
12 :doc-example
13 «(const? 'const?) ; a function
14 ; ↳ NIL»
15 :doc-example
16 «(const? 'pi) ; a mathematical constant
17 ; ↳ T»
18 :doc-group type)
19
20(defdoc (bignum? v)
21 «Return `T` if the argument is a bignum, `NIL` otherwise.»
22 :doc-group type
23 :doc-group number
24 :doc-see bignum)
25
26(defdoc (int? v)
27 «Return `T` if the argument is an integer, `NIL` otherwise.»
28 :doc-group type
29 :doc-group number
30 :doc-see int-valued?)
31
32(defdoc (str? v)
33 «Return `T` if the argument is a string, `NIL` otherwise.»
34 :doc-group type
35 :doc-see str
36 :doc-see str-utf8?)
37
38(defdoc (gensym? v)
39 «Return `T` if the argument is a gensym, `NIL` otherwise.»
40 :doc-group type
41 :doc-see sym?
42 :doc-see sym)
43
44(defdoc (ptr? v)
45 «Return `T` if the argument is an abstract pointer, `NIL` otherwise.»
46 :doc-group type
47 :doc-group number
48 :doc-see ptr)
49
50(defdoc (table? v)
51 «Return `T` if the argument is a table, `NIL` otherwise.»
52 :doc-group type
53 :doc-group table
54 :doc-see table)
55
56(defdoc (keyword? v)
57 «Return `T` if the argument is a keyword, `NIL` otherwise.»
58 :doc-group type)
59
60(defdoc (type-of v)
61 «Return the underlying type of the value.»
62 :doc-example
63 «(type-of 1)
64 ; ↳ fixnum»
65 :doc-example
66 «(type-of NIL)
67 ; ↳ null»
68 :doc-example
69 «(type-of T)
70 ; ↳ bool»
71 :doc-example
72 «(type-of "hello")
73 ; ↳ str»
74 :doc-example
75 «(type-of (arr 'u32 0 1 2))
76 ; ↳ (arr u32)»
77 :doc-group type
78 :doc-see size-of)
src/docs_vm.sl+93−0
@@ -0,0 +1,93 @@
1(doc-group vm
2 «VM-related functions.»)
3
4(defdoc (environment)
5 «Return the list of all bound top level symbols.»
6 :doc-group debug
7 :doc-group vm
8 :doc-see print-stack-trace)
9
10(defdoc (vm-stats (io *io-out*))
11 «Print various VM-related information, such as the number of GC
12 calls so far, heap and stack size, etc.»
13 :doc-group debug
14 :doc-group vm)
15
16(defdoc (tag-of v)
17 «Return the internal VM tag of the value.»
18 :doc-example
19 «(tag-of 1)
20 ; ↳ fixnum»
21 :doc-example
22 «(tag-of NIL)
23 ; ↳ special»
24 :doc-example
25 «(tag-of "hello")
26 ; ↳ cvalue»
27 :doc-example
28 «(tag-of (s32 1))
29 ; ↳ unboxed»
30 :doc-group vm
31 :doc-see type-of)
32
33(defdoc (builtin sym)
34 «Return the builtin associated with the symbol.
35
36 Throws an exception if no such builtin exists.»
37 :doc-example
38 «(builtin 'map)
39 ; ↳ #fn(map)»
40 :doc-example
41 «(builtin 'print)
42 ; ‼ arguments error: builtin "print" not found»
43 :doc-group vm)
44
45(defdoc (gc)
46 «Force a garbage collection run.
47
48 One does not need to execute this function manually since garbage
49 collection will happen automatically, based on the amount of data
50 allocated.»
51 :doc-group vm
52 :doc-see vm-stats)
53
54(defdoc (*prompt*)
55 «Function called by REPL to tell the user it's expecting input.
56
57 The default `*prompt*` function prints `#;> `, which by itself is a
58 commented-out expression, allowing the user to copy-paste the entire
59 line (with the prompt) to re-evaluate.»
60 :doc-group vm
61 :doc-see *interactive*)
62
63(defdoc *interactive*
64 «Variable indicating whether VM is running in "interactive" mode (`T`,
65 REPL is active) or not (`NIL`, REPL is not active).
66
67 Interactive mode can be forced by adding `-i` as the first command
68 line argument.»
69 :doc-group vm
70 :doc-see *prompt*)
71
72(defdoc *argv*
73 «The list of command line arguments.
74
75 If StreetLISP was started in interactive mode without a file specified
76 for execution, `*argv*` will be a list containing just one value - the
77 name of the `sl` executable.
78
79 Otherwise, the file specified for execution and the rest of the remaining
80 arguments will form the `*argv*` list.
81
82 StreetLISP's own options, such as `-i` and `-H ...` will be stripped
83 out in any case.»
84 :doc-example
85 «; $ sl -i -H 12345
86 *argv*
87 ; ↳ ("sl")»
88 :doc-example
89 «; $ sl script.sl -i abc
90 *argv*
91 ; ↳ ("script.sl" "-i" "abc")»
92 :doc-group vm
93 :doc-see *interactive*)
src/system.sl+4−18
@@ -388,6 +388,10 @@ · 387 unmodified lines
388 (io-flush *io-out*)388 (io-flush *io-out*)
389 (void)))389 (void)))
390 390
391;; chicken & egg problem - need doc logic to define a doc group
392(doc-group prop
393 «Dealing with properties of symbols.»)
394
391;;; standard procedures395;;; standard procedures
392 396
393(def (member item lst)397(def (member item lst)
@@ -488,9 +492,6 @@ · 94 unmodified lines
488 (nan? v))492 (nan? v))
489 (loop (car rest) (cdr rest))))))493 (loop (car rest) (cdr rest))))))
490 494
491(doc-group number
492 «Operations on numbers, mathematical constants.»)
493
494(def (negative? n)495(def (negative? n)
495 «Return `T` if `n` is a negative number. Shorthand for `(< n 0)`.»496 «Return `T` if `n` is a negative number. Shorthand for `(< n 0)`.»
496 :doc-group number497 :doc-group number
@@ -639,17 +640,11 @@ · 142 unmodified lines
639 rest)640 rest)
640 v))641 v))
641 642
642(doc-group misc
643 «Miscellaneous.»)
644
645(def (identity v)643(def (identity v)
646 «Return `v`.»644 «Return `v`.»
647 :doc-group misc645 :doc-group misc
648 v)646 v)
649 647
650(doc-group type
651 «Dealing with types.»)
652
653(def (rune? v)648(def (rune? v)
654 «Return `T` if the value is a rune, `NIL` otherwise.»649 «Return `T` if the value is a rune, `NIL` otherwise.»
655 :doc-group type650 :doc-group type
@@ -745,9 +740,6 @@ · 89 unmodified lines
745 740
746;;; list utilities741;;; list utilities
747 742
748(doc-group list
749 «Working with lists.»)
750
751(def (every pred lst)743(def (every pred lst)
752 «Return `T` if the predicate is true for _every_ element of the list,744 «Return `T` if the predicate is true for _every_ element of the list,
753 `NIL` otherwise.»745 `NIL` otherwise.»
@@ -2554,9 +2546,6 @@ · 1800 unmodified lines
2554 2546
2555;;; debugging utilities2547;;; debugging utilities
2556 2548
2557(doc-group debug
2558 «Debugging utilities.»)
2559
2560(defmacro (assert expr)2549(defmacro (assert expr)
2561 «Throw an exception if `expr` evaluates to `NIL`. Return `T` in any2550 «Throw an exception if `expr` evaluates to `NIL`. Return `T` in any
2562 other case.»2551 other case.»
@@ -2816,9 +2805,6 @@ · 253 unmodified lines
2816 2805
2817;;; table functions2806;;; table functions
2818 2807
2819(doc-group table
2820 «Tables of keys with associated values.»)
2821
2822(def (table->assoc-list ta)2808(def (table->assoc-list ta)
2823 «Return the table converted to an association list (pairs of each2809 «Return the table converted to an association list (pairs of each
2824 key and value).»2810 key and value).»

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