| @@ -29,7 +29,7 @@ doc)) cdaaar ((lst)) bounds-error ((seq index . msg)) even? ((n)) zero? ((n) · 28 unmodified lines |
| 29 | 29 | (id binds . body)) io-buffer-mode! ((io)) del! ((table key)) when ((cond . body)) vec? ((v)) min ((v . rest)) cddaar ((lst)) num->str ((n |
| 30 | 30 | (:base 10))) io? ((term)) eof-object? ((v)) help (((topic 'help) |
| 31 | 31 | (:print-header help-print-header) . rest)) mod ((a |
| 32 | | −n)) if ((cond then . else)) p32 (((n 0))) io-read-lines ((io)) io-line ((io)) sym-set-doc ((symbol |
| 32 | +n)) if ((cond then . else)) p32 (((n 0))) case ((expr . clauses)) io-read-lines ((io)) io-line ((io)) sym-set-doc ((symbol |
| 33 | 33 | doc-seq . formals-list)) macrocall? ((e)) trycatch ((try catch)) iterate ((fn zero n)) builtin ((sym)) table-values ((ta)) macroexpand ((e)) caadr ((lst)) type-of ((v)) top-level-value ((sym)) defstruct ((name |
| 34 | 34 | docs… options… (slot-1 DEFAULT) slot-2 slot-3) |
| 35 | 35 | (name (:type vec) (:named T) (:constructor T) (:conc-name T) (:predicate T) . slots)) caadar ((lst)) foldl1 ((fn |
| @@ -56,7 +56,7 @@ NIL) · 20 unmodified lines |
| 56 | 56 | n)) cdr ((lst)) / ((n . rest)) newline (((io *io-out*))) separate-doc-from-body ((body (doc |
| 57 | 57 | NIL))) cdadar ((lst)) foldr ((fn zero . seqs)) sqrt ((x)) reverse ((lst)) lz-pack ((data (level |
| 58 | 58 | 0))) *prompt* (NIL) member ((item lst)) bignum? ((v)) fixnum (((n 0))) f64 (((n 0.0))) memq ((item |
| 59 | | −lst)) str->num ((s (base NIL))) exp ((p)) caaaar ((lst)) io-column ((io)) traced? ((fn)) s64 (((n |
| 59 | +lst)) str->num ((s (base NIL))) exp ((p)) caaaar ((lst)) io-column ((io)) traced? ((fn)) cond (clauses) s64 (((n |
| 60 | 60 | 0))) io-flush ((io)) assoc ((key lst)) + (rest) cadadr ((lst)) foldr1 ((fn seq)) compare ((a |
| 61 | 61 | b)) length ((seq)) error (msg) print-exception ((e)) set-top-level-value! ((sym expr)) load ((path/io)) getpid (NIL) keyword? ((v)) aref ((sequence |
| 62 | 62 | subscript0 . rest)) sym? ((v)) defmacro ((form . body)) u64 (((n 0))) int-valued? ((x)) assv ((key |
| @@ -79,7 +79,7 @@ group error) "Errors and exception handling." io-eof? "Return `T` if `io` is cu · 16 unmodified lines |
| 79 | 79 | group 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.\n\nExamples:\n\n ; simple sort (note: symbols > numbers)\n (sort '(1a 1 0 2b e 3) <)\n ; ↳ (0 1 3 1a 2b e)\n\n ; sort in lexicographical order (as strings)\n (sort '(1a 1 0 2b e 3) < :key str)\n ; ↳ (0 1 1a 2b 3 e)\n\n ; sort by type (note how the numbers stayed in the same order)\n (sort '(3 \"a\" 1 a #\\a 2)\n (λ (a b) (< (type-of a) (type-of b))))\n ; ↳ (3 1 2 #\\a \"a\" a)" fixnum? "Return `T` if `v` is of a fixnum type, `NIL` otherwise." exit "Terminate the process with the specified status. Does not return.\nThe status is expected to be a string in case of an error.\n\nExamples:\n\n (exit) ; exit with status 0 (nil on Plan 9)\n (exit \"error\") ; exit with status 1 (\"error\" on Plan 9)" __finish "A function called right before exit by the VM.\n\nThe exit `status` is either `NIL` or a string referring to an error\ncondition." caaar "Shorthand for (car (car (car lst)))." 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.\n\nExample:\n\n ; is there any even number?\n (any even? '(1 3 5 7))\n ; ↳ NIL\n\n ; is there any string longer than one rune?\n (any (λ (s) (length> s 1))\n '(\"ab\" \"cd\" \"e\"))\n ; ↳ T" nthcdr "Return the reminder of the list after at most `n` elements, or `NIL`\nif the list is shorter.\n\nExamples:\n\n (def l '(a b c))\n (nthcdr l 1)\n ; ↳ (b c)\n (nthcdr l 2)\n ; ↳ (c)\n (nthcdr l 10)\n ; ↳ NIL" os-getenv "Return the value of the environment variable `name` or `NIL` if it's\nnot set." s8 "Construct a 8-bit signed number." 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.\n\nExamples:\n\n (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" 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." +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.\n\nExamples:\n\n (def s \"abc\")\n (assert (= (length s) 3))\n ; ↳ T\n (assert (eq? (str-rune s 0) #\\x))\n ; ‼ assertion failed: ..." vec->list "Return the vector converted to a list.\n\nExamples:\n\n (vec->list #(1 2 a))\n ; ↳ (1 2 a)" 1+ "Equivalent to `(+ n 1)` - increment by one." throw "Raise an exception consisting of a tag and a value.\n\nThis exception can be caught by `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 value associated with 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 |
| 80 | 80 | group list) "Working with lists." delete-file "Delete the file from the filesystem.\n\nThrows an IO error if file does not exist or it failed to be deleted." (doc |
| 81 | 81 | 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).\n\nExamples:\n\n (def q '(1 2 3 4 5))\n (set-cdr! q '(6 7))\n ; ↳ (1 6 7)\n q\n ; ↳ (1 6 7)" stacktrace "Return the current stack trace." eq? "Return `T` if `a` and `b` are the same object, `NIL` otherwise.\n\nExamples:\n\n (eq? 0.0 0)\n ; ↳ NIL\n\n (eq? 0 0)\n ; ↳ T\n\n (def a \"1\")\n (def b \"1\")\n (eq? a b)\n ; ↳ NIL\n\n (def a '(1))\n (def b '(1))\n (eq? a b)\n ; ↳ NIL" *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.\n\nExamples:\n\n (bound? 'bound?)\n ; ↳ T\n\n (bound? 'doesnotcompute)\n ; ↳ NIL" list->vec "Return the list converted to a vector.\n\nExamples:\n\n (list->vec '(1 2 a))\n ; ↳ #(1 2 a)" odd? "Return `T` if `n` is an odd integer, `NIL` otherwise." 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`.\n\nFunction definitions themselves may contain other definitions internal\nto the function.\n\nExamples:\n\n ; a function with documentation (first form)\n (def (f x)\n \"Return the square of doubled `x`.\n\n Examples:\n\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\n\n ; a variable (second form)\n (def x (length \"hello\"))\n x\n ; ↳ 5" 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.\n\nExamples:\n\n (str-rep \"oi\" 3)\n ; ↳ \"oioioi\"\n\n (str-rep #\\ы 5)\n ; ↳ \"ыыыыы\"\n\n (str-rep 'a 3)\n ; ↳ \"aaa\"\n\n (str-rep 1 5)\n ; ↳ \"11111\"" time "Display the elapsed time of evaluating `expr` to `*io-out*`, return\nthe result of the evaluated expression.\n\nExamples:\n\n (time (begin (sleep 0.1) 12345))\n ; ‼ Elapsed time: 0.10013356 seconds\n ; ↳ 12345" 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.\n\nExamples:\n\n (size-of \"hello\")\n ; ↳ 5\n\n (size-of (arr 'u32 1 2 3))\n ; ↳ 12\n\n (def b (buffer))\n (io-write b \"hello\")\n (size-of b)\n ; ↳ 5" sym "Return a symbol with the name being the concatenation of terms\nformatted as strings.\n\nThis is equivalent to `(sym (str …))`.\n\nExamples:\n\n (sym \"a\" 'b 1)\n ; ↳ ab1" 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`.\n\nExamples:\n\n (for 0 2 (λ (i) (print i)))\n ; ‼ 01" begin "Evaluate the expressions in order and return the result of the last\nexpression.\n\nExamples:\n\n (if 1\n (begin (print 1)\n (newline)\n 'ignored\n 'done)\n (print 0)\n (newline)\n 'else)\n ; ‼ 1\n ; ↳ done" 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.\n\nExamples:\n\n (const? 12345) ; a number\n ; ↳ T\n\n (const? 'const?) ; a function\n ; ↳ NIL\n\n (const? 'pi) ; a mathematical constant\n ; ↳ T" 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.\n\nExamples:\n\n (str-trim \" \\nhello\\t\\v\")\n ; ↳ \"hello\"\n\n (str-trim \" \\nhello\\t\\v\"\n (λ (r) (str-find \" \\v\" r)))\n ; ↳ \"\\nhello\\t\"\n\n (str-trim \"123abc!456def\"\n rune-numeric?\n rune-alphabetic?)\n ; ↳ \"abc!456\"" io-pos! "Change the current absolute position within the IO object in bytes,\nreturn the resulting position.\n\nExamples:\n\n (def f (buffer))\n (io-write f \"hello, world!\")\n (io-pos! f 64)\n ; ↳ 13\n (io-pos! f 7)\n ; ↳ 7\n (read f)\n ; ↳ world!" return "Return from the function with the specified value as the result.\n\nExamples:\n\n (def (f x) (when (not x)\n (return 0))\n (princ \"hi\")\n (newline)\n 1)\n (f 'a)\n ; ‼ hi\n ; ↳ 1\n (f NIL)\n ; ↳ 0" *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.\n\nExamples:\n\n (table)\n ; ↳ #table()\n\n (table 'a 1 'b 2)\n ; ↳ #table(a 1 b 2)" __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 recorded in this\ntable." 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.\n\nExamples:\n\n ; empty list\n (proper-list? NIL)\n ; ↳ T\n\n ; a list with one element\n (proper-list? '(1))\n ; ↳ T\n\n ; a pair, cdr of the cell is 2\n (proper-list? '(1 . 2))\n ; ↳ NIL\n\n ; on a circular list\n (proper-list? '#0=(1 . #0#))\n ; ↳ NIL" 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.\n\nExamples:\n\n (random 1)\n ; ↳ 1\n\n (random 10000000000000000000000000000000000)\n ; ↳ 5312781302474765749507273681609477\n\n (random 1.0)\n ; ↳ 0.69517" 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.\n\nExamples:\n\n (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\"" *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.\n\nExamples:\n\n (def a '(1 2 3))\n (reverse! a)\n ; ↳ (3 2 1)\n a\n ; ↳ (1) ; original list has been modified in-place" eval "Evaluate expression.\n\nExamples:\n\n (eval '(begin (set! x 1 y 2) (+ x y)))\n ; ↳ 3\n x\n ; ↳ 1\n y\n ; ↳ 2" cdaadr "Shorthand for (cdr (car (car (cdr lst))))." u32 "Construct a 32-bit unsigned number." cons "Return a cons cell containing two arguments.\n\nExamples:\n\n (cons 1 2)\n ; ↳ (1 . 2)\n\n (cons 1 '(2))\n ; ↳ (1 2)\n\n (cons 1 (cons 2 (cons 3 NIL)))\n ; ↳ (1 2 3)" filter "Return a copy of the list with only the elements of the original\nthat satisfy the predicate.\n\nExamples:\n\n (filter odd? '(0 1 2 3 4))\n ; ↳ (1 3)" 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?`." 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\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.\n\nExamples:\n\n (let ((a 123) (b 456)) ; first form\n (+ a b))\n ; ↳ 579\n\n (let loop ((a (iota 3 1))) ; second form\n (when a\n (princ (car a))\n (loop (cdr a))))\n ; ‼ 123\n ; ↳ NIL" del! "Remove any existing mapping for `key` and return the table.\n\nExamples:\n\n (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)\n t\n ; ↳ #table(a 1)" when "Shorthand for `(if cond body NIL)`.\n\nA non-empty body is required.\n\nExamples:\n\n (when (eq? cmd 'exit)\n (princ \"exiting!\")\n (newline)\n (exit))" vec? "Return `T` if `v` is a vector, `NIL` otherwise." min "Return the smallest among the arguments.\n\nExamples:\n\n (min 3 1 9 4)\n ; ↳ 1\n\n (min 'c 'h 'z 'a)\n ; ↳ a\n\n (min \"t\" \"g\" \"a\")\n ; ↳ \"a\"" cddaar "Shorthand for (cdr (cdr (car (car lst))))." 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.\n\nExamples:\n\n (num->str 65535 :base 16)\n ; ↳ \"FFFF\"\n\n (num->str (s8 -7))\n ; ↳ \"-7\"" io? "Return `T` if `term` is of `io` type, `NIL` otherwise." eof-object? "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." 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.\n\nExamples:\n\n (help str?) ; show documentation for str?\n (help groups) ; show documentation groups\n (help type group) ; list items for dealing with types\n (help group type) ; same as above\n (help str->*) ; find functions converting from strings\n (help *->str) ; find functions converting to strings\n (help *num*) ; find anything related to numbers" (doc |
| 82 | | −group array) "Arrays and vectors." mod "Return the remainder of the Euclidean division `a/n`.\n\nExamples:\n\n (mod 10 3)\n ; ↳ 1\n\n (mod -10 3)\n ; ↳ 2\n\n (mod -10 -3)\n ; ↳ 2\n\n (mod 10 -3)\n ; ↳ 1" 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.\n\nExamples:\n\n (def x '(1))\n (if x (begin (print \"yep!\") (newline) 'yes) 0)\n ; ‼ yep!\n ; ↳ yes\n (if (str? x) 1 (print \"nope!\") (newline) 'no)\n ; ‼ nope!\n ; ↳ no" p32 "Construct a 32-bit abstract pointer value." 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.\n\nExamples:\n\n ; read current process' segments on Plan 9\n (def seg (file (str \"/proc/\" (getpid) \"/segment\")))\n (io-read-lines seg)\n ; ↳ (\"Stack 1feff0000 1ffff0000 1\\n\"\n \"Text R 10000 70000 1\\n\"\n \"Data 70000 d0000 1\\n\"\n \"Bss d0000 1a0000 1\\n\"\n \"Bss 1fcff0000 1feff0000 1\\n\"\n \"Bss 1faff0000 1fcff0000 1\\n\")" 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." sym-set-doc "Set the documentation for the symbol." macrocall? "Return the macro application function if `e` refers to a macro call,\n`NIL` otherwise.\n\nExamples:\n\n (macrocall? '(car NIL))\n ; ↳ NIL\n\n (macrocall? '(let ((x 1)) 2))\n ; ↳ #fn(...)" trycatch "Return the result of evaluation of the expression `try` or, if an\nexception has been thrown, the one-argument function `catch`.\n\nExamples:\n\n (trycatch (+ 1 2) (λ (e) e))\n ; ↳ 3\n (trycatch (+ 1 NIL) (λ (e) e))\n ; ↳ (type-error num NIL)" (doc |
| 82 | +group array) "Arrays and vectors." mod "Return the remainder of the Euclidean division `a/n`.\n\nExamples:\n\n (mod 10 3)\n ; ↳ 1\n\n (mod -10 3)\n ; ↳ 2\n\n (mod -10 -3)\n ; ↳ 2\n\n (mod 10 -3)\n ; ↳ 1" 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.\n\nExamples:\n\n (def x '(1))\n (if x (begin (print \"yep!\") (newline) 'yes) 0)\n ; ‼ yep!\n ; ↳ yes\n (if (str? x) 1 (print \"nope!\") (newline) 'no)\n ; ‼ nope!\n ; ↳ no" 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.\n\nExamples:\n\n (case 'c ; match present\n (a 0)\n ((b c d) 1))\n ; ↳ b\n\n (case (+ 1 2) ; no matches, with else\n (a 0)\n (b 1)\n (else (print 'yay)\n (newline))\n ; ‼ yay\n\n (case \"c\" ; no matches, without else\n (\"a\" 0)\n (\"b\" 1))\n ; ↳ NIL" 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.\n\nExamples:\n\n ; read current process' segments on Plan 9\n (def seg (file (str \"/proc/\" (getpid) \"/segment\")))\n (io-read-lines seg)\n ; ↳ (\"Stack 1feff0000 1ffff0000 1\\n\"\n \"Text R 10000 70000 1\\n\"\n \"Data 70000 d0000 1\\n\"\n \"Bss d0000 1a0000 1\\n\"\n \"Bss 1fcff0000 1feff0000 1\\n\"\n \"Bss 1faff0000 1fcff0000 1\\n\")" 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." sym-set-doc "Set the documentation for the symbol." macrocall? "Return the macro application function if `e` refers to a macro call,\n`NIL` otherwise.\n\nExamples:\n\n (macrocall? '(car NIL))\n ; ↳ NIL\n\n (macrocall? '(let ((x 1)) 2))\n ; ↳ #fn(...)" trycatch "Return the result of evaluation of the expression `try` or, if an\nexception has been thrown, the one-argument function `catch`.\n\nExamples:\n\n (trycatch (+ 1 2) (λ (e) e))\n ; ↳ 3\n (trycatch (+ 1 NIL) (λ (e) e))\n ; ↳ (type-error num NIL)" (doc |
| 83 | 83 | group builtin) "Built-in operators." 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))) …]\n\nExamples:\n\n (iterate 1+ 5 3)\n ; ↳ (5 6 7)\n\n (iterate (λ (x) (* x x)) 2 5)\n ; ↳ (2 4 16 256 65536)\n\n (iterate (λ (s) (str-sub s 1)) \"hello\" 5)\n ; ↳ (\"hello\" \"ello\" \"llo\" \"lo\" \"o\")" *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.\n\nExamples:\n\n (builtin 'map)\n ; ↳ #fn(map)\n\n (builtin 'print)\n ; ‼ arguments error: builtin \"print\" not found" table-values "Return the list of all values of the table.\n\nExamples:\n\n (def t #table(a 1 b 2 c 1))\n (table-values t)\n ; ↳ (1 2 1)" macroexpand "Return a fully macro-expanded expression.\n\nExpansion will continue until no more macro calls are left.\n\nExamples:\n\n (let ((a 3) (b 4) (c 5))\n (macroexpand `(let* {[x ,a] [y ,b]} (+ x y ,c))))\n ; ↳ ((λ (x)\n ((λ (y)\n (+ x y 5))\n 4))\n 3)" caadr "Shorthand for (car (car (cdr lst)))." type-of "Return the underlying type of the value.\n\nExamples:\n\n (type-of 1)\n ; ↳ fixnum\n\n (type-of NIL)\n ; ↳ null\n\n (type-of T)\n ; ↳ bool\n\n (type-of \"hello\")\n ; ↳ str\n\n (type-of (arr 'u32 0 1 2))\n ; ↳ (arr u32)" top-level-value "Return the value bound to the symbol in the top level (global)\nenvironment.\n\nExamples:\n\n (def abc 1)\n (let {[abc 2]}\n (cons abc (top-level-value 'abc)))\n ; ↳ (2 . 1)\n abc\n ; ↳ 1" 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.\n\nExamples:\n\n (foldl1 * (iota 6 1))\n ; ↳ 720" buffer "Return an in-memory buffer for I/O, of `io` type.\n\nA buffer can be used for both reading and writing at the same\ntime." random-state? "Return `T` if the argument is a random state object, `NIL` otherwise.\n\nExamples:\n\n (random-state? 1)\n ; ↳ NIL\n\n (random-state? (make-random-state))\n ; ↳ T\n\n (random-state? *random-state*)\n ; ↳ T" 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.\n\nExamples:\n\n (assoc-list 'a 0 'b 1)\n ; ↳ ((a . 0) (b . 1))" builtin? "Return `T` if `v` is a built-in function implemented in C, `NIL`\notherwise.\n\nExamples:\n\n (builtin? map)\n ; ↳ T\n\n (builtin? macroexpand)\n ; ↳ NIL" 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.\n\nExamples:\n\n (str-map rune-upcase\n \"hello, world!\")\n ; ↳ \"HELLO, WORLD!\"\n\n (str-map (λ (r) (str r r))\n \"hello\")\n ; ↳ \"hheelllloo\"\n\n (str-map (λ (r) (and (not (rune-whitespace? r)) r))\n \"! this is great !\")\n ; ↳ \"!thisisgreat!\"" 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.\n\nExamples:\n\n (let ((a 3) (b 4) (c 5))\n (macroexpand-1 `(let* {[x ,a] [y ,b]} (+ x y ,c))))\n ; ↳ ((λ (x) ; note how the inner let* expression isn't expanded\n (let* ((y 4)) (+ x y 5)))\n 3)" +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.\n\nExamples:\n\n (remove-duplicates '(a 0 b c1 a b 3 c 5))\n ; ↳ (a 0 b c1 3 c 5)" str "Return concatenation of terms formatted as strings.\n\nThis is equivalent to `(princ terms…)`, except the string is\n_returned_, rather than printed.\n\nExamples:\n\n (str \"a\" 'b 1 #(0))\n ; ↳ \"ab1#(0)\"" 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." 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.\n\nExamples:\n\n (def s \"abc\")\n (assert-fail (= (length s) 3))\n ; ‼ assertion failed: ...\n (assert-fail (= s 1) type-error)\n ; ↳ T" 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-object>`) is returned if the IO object had no data.\n\nExamples:\n\n ; read one line from the kernel messages file\n (io-read-line (file \"/dev/kmesg\"))\n ; ↳ \"127 holes free\\n\"\n\n ; /dev/null has no data - EOF is returned\n (eof-object? (io-read-line (file \"/dev/null\")))\n ; ↳ T" and "Return `NIL` and stop evaluating the arguments if one of them\nevaluated to `NIL`. Return the last value otherwise.\n\nExamples:\n\n (and)\n ; ↳ T\n\n (and 1 2 (print 'yes) 3)\n ; ‼ yes\n ; ↳ 3\n\n (and 1 NIL (print 'yes) 3)\n ; ↳ NIL" 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.\n\nExamples:\n\n (map rune-upcase \"hello, world!\")\n ; ↳ \"HELLO, WORLD!\"\n (str-sub that 0 5)\n ; ↳ \"HELLO\"\n (map rune-downcase that)\n ; ↳ \"hello\"" (doc |
| 84 | 84 | group prop) "Dealing with properties of symbols." (doc group vm) "VM-related functions." 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.\n\nExamples:\n\n (equal? 0.0 0)\n ; ↳ NIL\n\n (equal? 0 0)\n ; ↳ T\n\n (def a \"1\")\n (def b \"1\")\n (equal? a b)\n ; ↳ T\n\n (def a '(1))\n (def b '(1))\n (equal? a b)\n ; ↳ T" cddar "Shorthand for (cdr (cdr (car lst)))." *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." unquote "Evaluate the expression, which is a part of a quasiquoted expression\nitself.\n\nShorthand for `(unquote expr)`.\n\nExamples:\n\n `(0 1 ,(+ 2 3)) ; same as (quasiquote (0 1 (unquote (+ 2 3))))\n ; ↳ (0 1 5)" or "Return the first evaluated argument that is not `NIL` and stop\nevaluating the rest of the arguments. Return `NIL` otherwise.\n\nExamples:\n\n (or)\n ; ↳ NIL\n\n (or 1 2 (print 'first) (print 'second) 3)\n ; ↳ 1\n\n (or NIL NIL (print 'first) (print 'second) 3)\n ; ‼ first" = "Numerical equality test. Return `T` if all numbers are equal,\n`NIL` otherwise." fn? "Return `T` if `v` is a function, `NIL` otherwise.\n\nExamples:\n\n (fn? (void))\n ; ↳ NIL\n\n (fn? map)\n ; ↳ T\n\n (fn? macroexpand)\n ; ↳ T" (doc |
| 85 | 85 | group 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.\n\nExamples:\n\n (subseq \"hello\" 1 2)\n ; ↳ \"e\"\n\n (subseq '(1 2 3) 0 2)\n ; ↳ (1 2)\n\n (subseq #(a b c) 2)\n ; ↳ #(c)" 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.\n\nExamples:\n\n (def a NIL)\n (def b NIL)\n (def c NIL)\n (set! a 1 b 2 c (+ a b))\n ; ↳ 3\n a\n ; ↳ 1\n b\n ; ↳ 2\n c\n ; ↳ 3" 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`." < "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 |
| @@ -87,7 +87,7 @@ group time) "Measuring, manipulating and displaying time." copy-tree "Return a · 1 unmodified line |
| 87 | 87 | group 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`.\n\nExamples:\n\n (expt 3 3) ; cube of 3\n ; ↳ 27\n\n (expt 27 (/ 1 3)) ; cube root of 27\n ; ↳ 3" 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.\n\nExamples:\n\n ; read current user on Plan 9\n (io-read-all (file \"/dev/user\"))\n ; ↳ \"glenda\"" 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.\n\nExamples:\n\n (io-write *stdout* \"hello\")\n ; ‼ hello\n ; ↳ 5\n\n (io-write *stdout* (u32 #x44434241) :little-endian)\n ; ‼ ABCD\n ; ↳ 4\n\n (io-write *stdout* #\\λ)\n ; ‼ λ\n ; ↳ 2\n\n (io-write *stdout* (arr 'rune #\\λ #\\= #\\l #\\a #\\m #\\b #\\d #\\a))\n ; ‼ λ=lambda\n ; ↳ 9" 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.\n\nExamples:\n\n (def t #table(a 1 b 2 c 1))\n (table-invert t)\n ; ↳ #table(1 a 2 b)" 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`.\n\nExamples:\n\n (div 10 3)\n ; ↳ 3\n\n (div -10 3)\n ; ↳ -4\n\n (div -10 -3)\n ; ↳ 4\n\n (div 10 -3)\n ; ↳ -3" princ "Print the arguments to *io-out* with `*print-readably*` set to `NIL`.\n\nExamples:\n\n (princ 1 2 \"abc\")\n ; ‼ 12abc" (doc |
| 88 | 88 | group 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.\n\nExamples:\n\n (last-cdr '(1 2 3))\n ; ↳ NIL\n\n (last-cdr '(1 2 . 3))\n ; ↳ 3" 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*`.\n\nExamples:\n\n (trace 'map)\n (map odd? (list (+ 1 2) (+ 3 4)))\n ; ‼ (map #fn(\"n170051S:\" #(even?) odd? 6) (3 7))\n ; ↳ (T T)" io-filename "Return the filename of the IO object.\n\nExamples:\n\n (def f (file \"/dev/random\"))\n (io-filename f)\n ; ↳ \"/dev/random\"\n (io-close f)\n (io-filename f) ; preserved even after it's closed\n ; ↳ \"/dev/random\"\n\n (io-filename *io-out*)\n ; ↳ \"*stdout*\"" let* "Same as the first form of `let` but each of the binding\nexpressions may reference any of the varibles bound previously.\n\nExamples:\n\n (let* ((a 1)\n (b (+ a 1))\n (c (+ b 1)))\n c)\n ; ↳ 3" gensym? "Return `T` if the argument is a gensym, `NIL` otherwise." (doc |
| 89 | 89 | group syntax) "StreetLISP syntax and macros." defdoc "Define documentation for a top level term.\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 and \"see also\"\nreferences.\n\nUseful in cases where setting the documentation for a term can't\n(or not preferred to) be done during the definition of said term.\nOne of those reasons could be that the term is a built-in function\nimplemented in C.\n\nExamples:\n\n (defdoc (func arg (arg2 0))\n \"Return something about the `arg` and `arg2`. This is a short\n description.\n\n This is the longer description, following the short one.\n\n Examples:\n\n (func 0)\n ; ↳ T\n\n (func 1 3)\n ; ↳ NIL\"\n :doc-group stuff\n :doc-see func2)\n (defdoc (func arg (:another-variant NIL)))" 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.\n\nExamples:\n\n (def t #table(a (1 2 3)))\n (def q (copy-table t))\n (eq? t q)\n ; ↳ NIL\n (eq? (get t 'a) (get q 'a))\n ; ↳ T" 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).\n\nExamples:\n\n (def q '(1 2 3 4 5))\n (set-car! q 0)\n ; ↳ (0 6 7)\n q\n ; ↳ (0 6 7)" 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.\n\nExamples:\n\n ; split the list into numbers and non-numbers\n (def q '(1a 1 0 2b e 3))\n (receive (nums other) (partition num? q)\n (print nums other)\n (newline))\n ; ↳ (1 0 3) (1a 2b e)" has? "Return `T` if the table has a value associated with the key, `NIL` otherwise.\n\nExamples:\n\n (def t #table(a 1 b 2))\n (has? t 'c)\n ; ↳ NIL\n (has? t 'a)\n ; ↳ T" vec "Construct a vector containing the specified arguments.\n\nExamples:\n\n (vec) ; empty vector\n ; ↳ #()\n\n (vec 1 2.5 \"a\" 'b)\n ; ↳ #(1 2.5 \"a\" b)" while "Evaluate the body expressions until `cond` evaluates to `NIL`.\n\nExamples:\n\n (def x 3)\n (while (> x 0)\n (princ #\\x)\n (set! x (1- x)))\n ; ‼ xxx" 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.\n\nExamples:\n\n (def l '(a b c))\n (nth l 0)\n ; ↳ a\n (nth l 2)\n ; ↳ c\n (nth l 10)\n ; ↳ NIL" cdr "Return the second element of a cons cell (tail of a list) or `NIL` if\nnot available.\n\nExamples:\n\n (cdr NIL)\n ; ↳ NIL\n\n (cdr '(1 2 3))\n ; ↳ (2 3)\n\n (cdr '(1 . 2))\n ; ↳ 2" / "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.\n\nExamples:\n\n (/ 2)\n ; ↳ 0.5\n\n (/ 7 2 2)\n ; ↳ 1.75\n\n (/ 10 -2)\n ; ↳ -5 ; a fixnum\n\n (/ 6.9 1.9)\n ; ↳ 3.6315…" 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.\n\nExamples:\n\n (foldr cons NIL (iota 5))\n ; ↳ (0 1 2 3 4)\n\n (foldr + 0 (iota 5))\n ; ↳ 10\n\n (foldr (λ (x y a) (+ (* x y) a)) 0 (iota 5) (iota 5))\n ; ↳ 30\n\n (foldr (λ (x y a) (cons x (cons y a))) NIL (iota 5) (vec 'a 'b 'c))\n ; ↳ (0 a 1 b 2 c)" sqrt "Return the square root of `x`.\n\nExamples:\n\n (sqrt 9.0)\n ; ↳ 3.0" reverse "Return the list with its elements in reverse order.\n\nThe original list is copied to construct the reversed version.\n\nExamples:\n\n (def a '(1 2 3))\n (reverse a)\n ; ↳ (3 2 1)\n a\n ; ↳ (1 2 3)" 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?`.\n\nExamples:\n\n (member 1 '(3 2 1 0))\n ; ↳ (1 0)\n\n (member 1 '(2 3))\n ; ↳ NIL" bignum? "Return `T` if the argument is a bignum, `NIL` otherwise." fixnum "Construct a fixnum." f64 "Construct a 64-bit floating point number." memq "Return the tail of a list beginning with the item, or `NIL` otherwise.\nList elements are compared to the `item` using `eq?`." str->num "Return the number using the radix `base` in the string `s`.\n\nReturns `NIL` if the number could not be parsed or there were\nleft-over trailing characters.\n\nExamples:\n\n (str->num \"1.2\")\n ; ↳ 1.2\n\n (str->num \"#x123\")\n ; ↳ 291\n\n (str->num \"ffff\" 16)\n ; ↳ 65535\n\n (str->num \"777\" 8)\n ; ↳ 511" exp "Return the exponential - value of `e` (natural logarithms base) raised\nto the power of `p`.\n\nExamples:\n\n (exp 1)\n ; ↳ 2.71828… ; e" (doc |
| 90 | | −group 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.\n\nExamples:\n\n (traced? map)\n ; ↳ NIL\n (trace 'map)\n (traced? map)\n ; ↳ T\n (untrace 'map)\n (traced? map)\n ; ↳ NIL" (doc |
| 90 | +group 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.\n\nExamples:\n\n (traced? map)\n ; ↳ NIL\n (trace 'map)\n (traced? map)\n ; ↳ T\n (untrace 'map)\n (traced? map)\n ; ↳ NIL" 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.\n\nExamples:\n\n (def x 8)\n (cond ((sym? x) \"symbol\")\n ((str? x) \"string\")\n ((+ x 1) => sqrt))\n ; ↳ 3.0\n\n (def x \"hello\")\n (cond ((sym? x) 0)\n ((length x)))\n ; ↳ 5\n\n (def x 0)\n (case ((positive? x) 10)\n ((negative? x) -10)\n (else 'oops))\n ; ↳ oops" (doc |
| 91 | 91 | group 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?`.\n\nExamples:\n\n (def L (assoc-list 'a 0 'b 1))\n (assoc 'b L)\n ; ↳ (b . 1)\n (assoc 'c L)\n ; ↳ NIL" + "Return sum of the arguments or `0` when none specified." cadadr "Shorthand for (car (cdr (car (cdr lst))))." foldr1 "Same as `foldr` but using the first element of the sequence as the\ninitial accumulator.\n\nExamples:\n\n (foldr1 + (iota 10))\n ; ↳ 45" compare "Return -1 if `x` is less than `y`, 0 if equal, and `1` if `y` is\ngreater than `x`.\n\nExamples:\n\n (compare 'a 'b)\n ; ↳ -1\n\n (compare 1 1)\n ; ↳ 0\n\n (compare \"b\" \"a\")\n ; ↳ 1" 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.\n\nExamples:\n\n (length \"абвгд\")\n ; ↳ 5\n (length #(abc 123))\n ; ↳ 2\n (length #table(0 a 1 b 2 c))\n ; ↳ 3\n (length (arr 'u32 1 2 3 4))\n ; ↳ 4\n (length '(1 2 3 4 5))\n ; ↳ 5\n (length '(1 2 3 4 . 5)) ; improper list\n ; ‼ type error: expected cons, got fixnum: 5\n (length '#0=(1 . #0#)) ; circular list\n ; ↳ NIL" error "Raise an error exception." *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)`.\n\nExamples:\n\n (def e (list (list *stdin* 3 10) 'type-error 'str 123))\n (print-exception e)\n ; ‼ *stdin*:3:10: type error: expected str, got fixnum: 123" 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! …)`.\n\nExamples:\n\n (let {[abc 2]}\n (set-top-level-value! 'abc 123)\n abc)\n ; ↳ 2\n abc\n ; ↳ 123" 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.\n\nExamples:\n\n (load \"stuff.sl\")" 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.\n\nExamples:\n\n (def a '((1 #(2 (3)) 4)))\n (aref a 0)\n ; ↳ (1 (2 (3)) 4)\n (aref a 1)\n ; ‼ index 1 out of bounds\n (aref a 0 0)\n ; ↳ 1\n (aref a 0 1 0)\n ; ↳ 2\n (aref a 0 2)\n ; ↳ 4" sym? "Return `T` if `v` is a symbol, `NIL` otherwise." defmacro "Define a new macro.\n\nExamples:\n\n (defmacro (inc! v)\n \"Increments and returns the value.\"\n :doc-group my-cool-macros\n :doc-see my-other-cool-macro\n (if (num? v)\n (1+ v)\n `(set! ,v (1+ ,v))))\n (inc! 1)\n ; ↳ 2\n (set! x 1)\n (inc! x)\n ; ↳ 2\n x\n ; ↳ 2" 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`.\n\nExamples:\n\n (int-valued? -123.0)\n ; ↳ T\n\n (int-valued? -123.1)\n ; ↳ NIL" 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.\n\nExamples:\n\n (def v #vec(1 2 \"three\"))\n (def q (copy-vec v))\n (eq? v q)\n ; ↳ NIL\n (equal? v q)\n ; ↳ T\n (map eq? v q)\n ; ↳ #(T T T)" 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.\n\nExamples:\n\n (eqv? 0.0 0)\n ; ↳ NIL\n\n (eqv? 0 0)\n ; ↳ T\n\n (def a \"1\")\n (def b \"1\")\n (eqv? a b)\n ; ↳ T\n\n (def a '(1))\n (def b '(1))\n (eqv? a b)\n ; ↳ NIL" +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.\n\nExamples:\n\n (list) ; empty list\n ; ↳ NIL\n\n (list 1 2.5 \"a\" 'b)\n ; ↳ (1 2.5 \"a\" b)" __init_globals "Initialize globals that need to be set at load time." +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.\n\nExamples:\n\n (def a '(4 5 6))\n (revappend a '(3 2 1))\n ; ↳ (6 5 4 3 2 1)\n a\n ; ↳ (4 5 6)" quote "Leave the expression unevaluated.\n\nShorthand for `(quote expr)`.\n\nExamples:\n\n '(0 1 (+ 2 3)) ; same as (quote (0 1 (+ 2 3)))\n ; ↳ (0 1 (+ 2 3))" 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.\n\nExamples:\n\n (def a '(4 5 6))\n (nreconc a '(3 2 1))\n ; ↳ (6 5 4 3 2 1)" defc*r "Define a shorthand for list access using `car` and `cdr`.\n\nExamples:\n\n (defc*r caaaaaaaaddr) ; define the function" (doc |
| 92 | 92 | group 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.\n\nExamples:\n\n (prog1 (+ 1 2 3)\n (print \"hi\")\n (newline))\n ; ↳ 6" logior "Return the result of bitwise OR (inclusive OR) operation on integers.\n\nExamples:\n\n (logior)\n ; ↳ 0\n\n (logior 2)\n ; ↳ 2\n\n (logior 2 3)\n ; ↳ 3\n\n (logior 2 3 4)\n ; ↳ 7" cadr "Shorthand for `(car (cdr lst))`, that is, _first element of the\nsecond element_.\n\nExamples:\n\n (cadr '(1 2 3))\n ; ↳ 2\n\n (cadr '(1))\n ; ↳ NIL\n\n (cadr NIL)\n ; ↳ NIL" cdadr "Shorthand for (cdr (car (cdr lst)))." (doc |
| 93 | 93 | group 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))." div0 "Return the quotient of the truncated division `a/n`.\n\nExamples:\n\n (div0 10 3)\n ; ↳ 3\n\n (div0 -10 3)\n ; ↳ -3\n\n (div0 -10 -3)\n ; ↳ 3\n\n (div0 10 -3)\n ; ↳ -3" set-syntax! "Associate a macro name with its application function." mod0 "Return the remainder of the truncated division `a/n`.\n\nExamples:\n\n (mod0 10 3)\n ; ↳ 1\n\n (mod0 -10 3)\n ; ↳ -1\n\n (mod0 -10 -3)\n ; ↳ -1\n\n (mod0 10 -3)\n ; ↳ 1" last-pair "Return the last cell (pair) of the list.\n\nExamples:\n\n (last-pair '(1 2 3))\n ; ↳ (3)\n\n (last-pair '(1 2 . 3))\n ; ↳ (2 . 3)" path-cwd "Return the full path to the current directory of the process, or\nchange it to the path specified with `to` argument." (doc |
| @@ -114,7 +114,8 @@ group number) "Operations on numbers, mathematical constants." cdaddr "Shorthan · 20 unmodified lines |
| 114 | 114 | (:doc-group . builtin)) *random-state* ((:doc-group . random) (:doc-see . make-random-state) (:doc-see . random-state?)) io->str ((:doc-group . io)) bound? ((:doc-group . builtin)) list->vec ((:doc-group . list) |
| 115 | 115 | (:doc-see . vec->list)) odd? ((:doc-group . number) (:doc-see . even?)) def ((:doc-group . syntax) |
| 116 | 116 | (:doc-see . defdoc) |
| 117 | | −(:doc-see . set!)) list? ((:doc-group . list) |
| 117 | +(:doc-see . set!) |
| 118 | +(:doc-see . let)) list? ((:doc-group . list) |
| 118 | 119 | (:doc-group . type) (:doc-see . list) (:doc-see . proper-list?)) str-rep ((:doc-group . string)) time ((:doc-group . debug)) size-of ((:doc-group . misc) |
| 119 | 120 | (:doc-see . type-of)) sym ((:doc-group . misc) (:doc-see . sym?)) tanh ((:doc-group . number)) for ((:doc-group . syntax) |
| 120 | 121 | (:doc-see . while)) begin ((:doc-group . syntax) (:doc-see . prog1)) const? ((:doc-group . type)) str-trim ((:doc-group . string) |
| @@ -137,8 +138,9 @@ group number) "Operations on numbers, mathematical constants." cdaddr "Shorthan · 16 unmodified lines |
| 137 | 138 | (:doc-see . max)) cddaar ((:doc-group . list)) num->str ((:doc-group . string)) io? ((:doc-group . io) |
| 138 | 139 | (:doc-group . type)) eof-object? ((:doc-group . io) (:doc-group . type)) help ((:doc-group . doc)) mod ((:doc-group . number) |
| 139 | 140 | (:doc-see . div) (:doc-see . mod0)) if ((:doc-group . syntax) (:doc-see . when) (:doc-see . unless)) p32 ((:doc-group . number) |
| 140 | | −(:doc-see . p64) (:doc-see . ptr)) io-read-lines ((:doc-group . io) (:doc-see . io-read-line) (:doc-see . io-read-all)) io-line ((:doc-group . io) |
| 141 | | −(:doc-see . io-column) (:doc-see . io-line!)) sym-set-doc ((:doc-group . doc)) macrocall? ((:doc-group . syntax) |
| 141 | +(:doc-see . p64) (:doc-see . ptr)) case ((:doc-group . syntax) (:doc-see . cond)) io-read-lines ((:doc-group . io) |
| 142 | +(:doc-see . io-read-line) (:doc-see . io-read-all)) io-line ((:doc-group . io) (:doc-see . io-column) |
| 143 | +(:doc-see . io-line!)) sym-set-doc ((:doc-group . doc)) macrocall? ((:doc-group . syntax) |
| 142 | 144 | (:doc-see . macroexpand-1) (:doc-see . macroexpand)) trycatch ((:doc-group . syntax) (:doc-see . catch) |
| 143 | 145 | (:doc-see . unwind-protect)) iterate ((:doc-group . list)) *syntax-environment* ((:doc-group . syntax) |
| 144 | 146 | (:doc-see . get-syntax) (:doc-see . set-syntax!)) builtin ((:doc-group . vm)) table-values ((:doc-group . table) |
| @@ -161,8 +163,10 @@ group number) "Operations on numbers, mathematical constants." cdaddr "Shorthan · 16 unmodified lines |
| 161 | 163 | (:doc-see . *prompt*)) or ((:doc-group . syntax) (:doc-see . and) (:doc-see . not)) = ((:doc-group . number) |
| 162 | 164 | (:doc-group . compare) (:doc-group . builtin)) fn? ((:doc-group . type) (:doc-see . fn) (:doc-see . builtin?) |
| 163 | 165 | (:doc-see . closure?) (:doc-group . builtin)) caaadr ((:doc-group . list)) make-system-image ((:doc-group . vm)) subseq ((:doc-group . list) |
| 164 | | −(:doc-see . str-sub) (:doc-see . copy-list) (:doc-see . nthcdr)) set! ((:doc-group . syntax) (:doc-see . set-top-level-value!)) vm-stats ((:doc-group . debug) |
| 165 | | −(: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) |
| 166 | +(:doc-see . str-sub) (:doc-see . copy-list) (:doc-see . nthcdr)) set! ((:doc-group . syntax) (:doc-see . set-top-level-value!) |
| 167 | +(:doc-see . let)) vm-stats ((:doc-group . debug) (:doc-group . vm)) ptr ((:doc-group . number) |
| 168 | +(:doc-see . p32) (:doc-see . p64) |
| 169 | +(:doc-see . ptr?)) caddar ((:doc-group . list)) print-stack-trace ((:doc-group . error) |
| 166 | 170 | (:doc-see . stacktrace)) *stdin* ((:doc-group . io) (:doc-see . *stdout*) (:doc-see . *stderr*)) cosh ((:doc-group . number)) < ((:doc-group . compare) |
| 167 | 171 | (:doc-group . builtin)) copy-tree ((:doc-group . list) (:doc-see . copy-list)) f32 ((:doc-group . number) |
| 168 | 172 | (:doc-see . f64)) sin ((:doc-group . number)) io-copy ((:doc-group . io) |
| @@ -206,9 +210,11 @@ group number) "Operations on numbers, mathematical constants." cdaddr "Shorthan · 37 unmodified lines |
| 206 | 210 | (:doc-see . num->str)) exp ((:doc-group . number)) +most-negative-fixnum+ ((:doc-group . number) |
| 207 | 211 | (:doc-see . +most-positive-fixnum+)) caaaar ((:doc-group . list)) io-column ((:doc-group . io) |
| 208 | 212 | (:doc-see . io-line) (:doc-see . io-column!)) traced? ((:doc-group . debug) (:doc-see . trace) |
| 209 | | −(:doc-see . untrace)) s64 ((:doc-group . number) |
| 210 | | −(:doc-see . u64)) io-flush ((:doc-group . io) (:doc-see . io-discard-buffer) (:doc-see . io-buffer-mode)) assoc ((:doc-group . list) |
| 211 | | −(:doc-see . assoc-list) (:doc-see . assq) (:doc-see . assv)) + ((:doc-group . number) (:doc-group . builtin)) cadadr ((:doc-group . list)) foldr1 ((:doc-group . list) |
| 213 | +(:doc-see . untrace)) cond ((:doc-group . syntax) |
| 214 | +(:doc-see . case)) s64 ((:doc-group . number) (:doc-see . u64)) io-flush ((:doc-group . io) (:doc-see . io-discard-buffer) |
| 215 | +(:doc-see . io-buffer-mode)) assoc ((:doc-group . list) (:doc-see . assoc-list) (:doc-see . assq) |
| 216 | +(:doc-see . assv)) + ((:doc-group . number) |
| 217 | +(:doc-group . builtin)) cadadr ((:doc-group . list)) foldr1 ((:doc-group . list) |
| 212 | 218 | (:doc-see . foldr) (:doc-see . foldl1)) compare ((:doc-group . compare) (:doc-group . builtin)) length ((:doc-group . array) |
| 213 | 219 | (:doc-group . list) (:doc-group . table) (:doc-see . proper-list?)) error ((:doc-group . error)) *io-err* ((:doc-group . io) |
| 214 | 220 | (:doc-see . *io-out*) (:doc-see . *io-in*) (:doc-see . with-bindings)) print-exception ((:doc-group . error) |