Skip to content

Commit

Permalink
Merge pull request #92 from skx/87-docs
Browse files Browse the repository at this point in the history
Minor documentation fixes
  • Loading branch information
skx authored Nov 12, 2022
2 parents 4b97684 + 4b5f66c commit 508f7c2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
31 changes: 31 additions & 0 deletions PRIMITIVES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* [Core Primitives](#core-primitives)
* [Standard Library](#standard-library)
* [Type Checking](#type-checking)
* [Testing](#testing)
* [See Also](#see-also)


Expand Down Expand Up @@ -73,6 +74,8 @@ Special forms are things that are built into the core interpreter, and include:
* Read a form from the specified string.
* `set!`
* Set the value of a variable.
* `symbol`
* Create a new symbol from the given string.
* `try`
* Error-catching warpper, demonstrated in [try.lisp](try.lisp).

Expand Down Expand Up @@ -105,6 +108,8 @@ Things you'll find here include:
* Note that multiple arguments are supported, not just two.
* `arch`
* Return the operating system architecture.
* `base`
* Convert the specified integer to a string, in the given base.
* `car`
* Return the first item of a list.
* `cdr`
Expand All @@ -128,6 +133,10 @@ Things you'll find here include:
* `date`
* Return details of today's date, as a list.
* Demonstrated in [time.lisp](time.lisp).
* `dec2bin`
* Convert the specified integer to a binary string.
* `dec2hex`
* Convert the specified integer to a hexadecimal string.
* `directory?`
* Does the given path represent something that exists, and is a directory?
* `directory:entries`
Expand Down Expand Up @@ -173,12 +182,21 @@ Things you'll find here include:
* Return the time, in milliseconds.
* `nil?`
* Is the given value nil, or an empty list?
* `nth`
* Return the nth element of the supplied list.
* `now`
* Return the number of seconds past the Unix Epoch.
* `number`
* Convert the specified string to a number. We accept base 2, 10, and 16.
* Use the appropriate prefix in your input, for example "0b10101", or "0xFF".
* `ord`
* Return the ASCII code of the specified character, or the first character of the supplied string.
* `os`
* Return a string describing the current operating-system.
* `pad:left`
* Pad the specified string to the given length, by prepending to it.
* `pad:right`
* Pad the specified string to the given length, by appending to it.
* `print`
* Output the specified string, or format string + values.
* `set`
Expand Down Expand Up @@ -351,6 +369,8 @@ Functions here include:
* Is the given thing a string?
* `strlen`
* Return the length of the specified string.
* `substr`
* Return part of the specified string, identified by offset and length.
* `symbol?`
* Is the given thing a symbol?
* `take`
Expand Down Expand Up @@ -407,6 +427,17 @@ If multiple types are permitted then just keep appending things, for example:
* Allows either a list, or a number.



# Testing

There is a simple set of tests written in Lisp, using a macro to define them easily, which can be viewed:

* [lisp-tests.lisp](lisp-tests.lisp)

Adding new tests is easy enough that this file should be updated over time with new test-cases.



# See Also

* [README.md](README.md)
Expand Down
8 changes: 6 additions & 2 deletions stdlib/stdlib/stdlib.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@

;; Convert a number to a binary string.
(set! dec2bin (fn* (n:number)
"Convert the given number to a binary string representation of that number."
"Convert the given number to a binary string representation of that number.
See also: dec2hex"
(base n 2)))

;; Convert a number to a hexadecimal string.
(set! dec2hex (fn* (n:number)
"Convert the given number to a hexadecimal string representation."
"Convert the given number to a hexadecimal string representation.
See also: dec2bin"
(base n 16)))

;; Useful for creating a list of numbers
Expand Down
2 changes: 1 addition & 1 deletion test.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


;; Instead of just (+ 1 2) we allow multiple args
(print "Our mathematical functions allow 2+ arguments, e.g: %s = %s"
(print "Our mathematical functions allow 2+ arguments, e.g: %s = %d"
(quote (+ 1 2 3 4 5 6)) (+ 1 2 3 4 5 6))


Expand Down

0 comments on commit 508f7c2

Please sign in to comment.