From af78e1f67f3ccc45b084425d44fa52a9ade4f485 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Thu, 30 Dec 2021 19:44:15 +0100 Subject: [PATCH] Update spec --- README.md | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index c87f13d..993b89c 100644 --- a/README.md +++ b/README.md @@ -6,11 +6,11 @@ nolambda is a collection of native [uwu](https://github.com/EliasFleckenstein03/ ### `nolambda:flow` - `nolambda:flow:linear`: Accepts an arbitrary number of arguments of arbitrary type, but at least one and evaulates all of them in order. Returns the last argument. -- `nolambda:flow:error`: Accepts a string as $0, prints the string to stderr and exits the program with failure. +- `nolambda:flow:error`: Accepts a string as $0, prints the string to stderr and exits the program with failure. Returns `:nil:nil` in theory. ### `nolambda:io` -- `nolambda:io:print`: Accepts a string as $0 and prints it to stdout, followed by a newline. +- `nolambda:io:print`: Accepts a string as $0 and prints it to stdout, followed by a newline. Returns $0. - `nolambda:io:scan`: Reads a line from stdin and returns it as a string, without the newline character at the end. This is interally using readline. ### `nolambda:fs` @@ -18,19 +18,26 @@ nolambda is a collection of native [uwu](https://github.com/EliasFleckenstein03/ Note: all file paths are relative to the _directory the program was started from_. - `nolambda:fs:read`: Accepts a file name (string) as $0 and returns it's contents as a string. Causes an error if the file does not exist. -- `nolambda:fs:write`: Accepts a file name (string) as $0 and overwrites it with the contents in $1 (string). Causes an error if the file could not be written. -- `nolambda:fs:remove`: Accepts a file name (string) as $0 and removes it from the file system. Causes an error if the file could not be removed, but does not cause an error if the file does not exist. +- `nolambda:fs:write`: Accepts a file name (string) as $0 and overwrites it with the contents in $1 (string). Causes an error if the file could not be written. Returns `:bool:true` if the file was freshly created, `:bool:false` if it was overwritten. +- `nolambda:fs:remove`: Accepts a file name (string) as $0 and removes it from the file system. Causes an error if the file could not be removed, but does not cause an error if the file does not exist. Returns `:bool:true` if the file existed and was removed, `:bool:false` otherwise. - `nolambda:fs:exists`: Accepts a file name (string) as $0 and returns `:bool:true` if it exists, `:bool:fase` else. ### `nolambda:os` -- `nolambda:os:exit`: Optionally takes an exit code (integer) as $0 and exits the program with the given exit code, or 0 if no exit code was given. -- `nolambda:os:sleep`: Takes an integer as $0 and pauses the execution of the program for $1 milliseconds. +- `nolambda:os:exit`: Optionally takes an exit code (integer) as $0 and exits the program with the given exit code, or 0 if no exit code was given. Returns `:nil:nil` in theory. +- `nolambda:os:sleep`: Takes an integer as $0 and pauses the execution of the program for $1 milliseconds. Returns `:nil:nil`. - `nolambda:os:execute`: Takes a command (string) as $0 and executes it as a shell command. Returns the exit code of the command as an integer. +- `nolambda:os:time`: Returns the current unix time as an integer. ### `nolambda:global` -- `nolambda:global:set`: Creates or overwrites a global variable named $0 (string) and puts the contents of $1 (arbitrary type) into it. -- `nolambda:global:get`: Gets the global variable named $0 (string). Causes an error if the variable does not exist. +- `nolambda:global:set`: Creates or overwrites a global variable named $0 (string) and puts the contents of $1 (arbitrary type) into it. Returns `:bool:false` if the variable existed previously and was updated, `:bool:true` if it was created. +- `nolambda:global:get`: Returns the global variable named $0 (string). Causes an error if the variable does not exist. - `nolambda:global:exists`: Returns `:bool:true` if the global variable named $0 (string) exists, `:bool:false` else. -- `nolambda:global:delete`: Deletes the global variable named $0 (string). Does **not** cause an error if the variable does not exist. +- `nolambda:global:delete`: Deletes the global variable named $0 (string). Returns `:bool:true` if the variable existed previously, `:bool:false` else. + +### `nolambda:random` + +- `nolambda:random:random`: Returns a pseudorandom integer between $0 (integer) and $1 (integer). The upper bound is exclusive, the lower bound inclusive. Causes an error if the range is bigger than `nolambda:random:max`. +- `nolambda:random:max`: Returns RAND_MAX, which is usually 32767. +- `nolambda:random:seed`: Sets the random seed to $0 (integer) and returns `:nil:nil`. -- 2.44.0