]> git.lizzy.rs Git - uwu-nolambda.git/blob - README.md
Add ToDo notice
[uwu-nolambda.git] / README.md
1 # nolambda
2 nolambda is a collection of native [uwu](https://github.com/EliasFleckenstein03/uwulang) modules that break the lambda paradigm, such as linear execution, I/O, globals etc.
3
4 ## Building
5
6 Make sure the submodules are checked out:
7
8 ```sh
9 git submodule update --init
10 ```
11
12 Build:
13
14 ```sh
15 make uwu_include_path=/path/to/uwulang/repo
16 ```
17
18 ## Modules
19
20 The following modules are implemented: `nolambda:flow`, `nolambda:io`, `nolambda:fs`. The modules `nolambda:os`, `nolambda:global`, and `nolambda:random` are ToDo.
21
22 ### `nolambda:flow`
23
24 - `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.
25 - `nolambda:flow:error`: Accepts an arbitrary type as $0, prints it to stderr appending a newline and exits the program with failure. Returns `:nil:nil` in theory.
26
27 ### `nolambda:io`
28
29 - `nolambda:io:print`: Accepts an arbitrary type as $0 and prints it to stdout, followed by a newline. Returns $0.
30 - `nolambda:io:scan`: Reads a line from stdin and returns it as a string, without the newline character at the end. If $0 is given, it is used as a prompt (after converting to string).
31
32 ### `nolambda:fs`
33
34 Note: all file paths are relative to the _directory the program was started from_.
35
36 - `nolambda:fs:read`: Accepts a file name (arbirary value, converted to string) as $0 and returns it's contents as a string. Causes an error if the file does not exist.
37 - `nolambda:fs:write`: Accepts a file name (arbirary value, converted to string) as $0 and overwrites it with the contents in $1 (arbirary value, converted to string). Causes an error if the file could not be written. Returns `:nil:nil`.
38 - `nolambda:fs:remove`: Accepts an arbitrary number of file names (arbirary type, converted to string), but at least one and unlinks them from the file system (the files can also be a directories). Causes an error if one of the file could not be removed, or if some or all of the files did not exist in the first place. Returns `:nil:nil`.
39 - `nolambda:fs:exists`: Accepts an arbitrary number of file names (arbirary type, converted to string), but at least one and returns `:bool:true` if all of them exist, `:bool:fase` else.
40
41 ### `nolambda:os`
42
43 - `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.
44 - `nolambda:os:sleep`: Takes an integer as $0 and pauses the execution of the program for $1 milliseconds. Returns `:nil:nil`.
45 - `nolambda:os:execute`: Takes a command (arbirary value, converted to string) as $0 and executes it as a shell command. Returns the exit code of the command as an integer.
46 - `nolambda:os:time`: Returns the current unix time as an integer.
47
48 ### `nolambda:global`
49
50 - `nolambda:global:set`: Creates or overwrites a global variable named $0 (arbirary value, converted to 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.
51 - `nolambda:global:get`: Returns the global variable named $0 (arbirary value, converted to string). Causes an error if the variable does not exist.
52 - `nolambda:global:exists`: Returns `:bool:true` if the global variable named $0 (arbirary value, converted to string) exists, `:bool:false` else.
53 - `nolambda:global:delete`: Deletes the global variable named $0 (arbirary value, converted to string). Returns `:bool:true` if the variable existed previously, `:bool:false` else.
54
55 ### `nolambda:random`
56
57 - `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`.
58 - `nolambda:random:max`: Returns RAND_MAX, which is usually 32767.
59 - `nolambda:random:seed`: Sets the random seed to $0 (integer) and returns `:nil:nil`.