Skip to content

Commit 23b744f

Browse files
committed
Update README
1 parent efe20d5 commit 23b744f

File tree

1 file changed

+33
-17
lines changed

1 file changed

+33
-17
lines changed

README.md

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,31 @@
55

66
Written by [Kacarott](https://github.com/Kacarott) and [JohanWiltink](https://github.com/JohanWiltink)
77

8+
### Install
89

9-
### Running example tests
10-
11-
**Requirements:**
12-
- `node`
13-
- `npm`
14-
15-
From within this directory:
16-
17-
1. Install dependancies with `npm install`
18-
2. Run tests with `npm test`
10+
```bash
11+
$ npm i --save @codewars/lambda-calculus
12+
```
1913

2014
### Usage
2115

16+
> NOTE: When writing tests on Codewars, you can use the predefined wrapper module "./files.js" to get
17+
> the solution file instead of using `fs` like below.
18+
2219
```javascript
20+
import { readFileSync } from "fs";
2321
// Import module
24-
const LC = require("./src/lambda-calculus.js");
22+
import * as LC from "@codewars/lambda-calculus";
2523

2624
// Set config options
2725
LC.config.purity = "Let";
2826
LC.config.numEncoding = "Church";
2927

28+
const code = readFileSync("solution.lc", {encoding: "utf8"});
3029
// Compile
31-
const solution = compile().TRUE;
30+
const solution = compile(code).TRUE;
3231
// or
33-
const {TRUE,FALSE} = compile();
32+
const {TRUE,FALSE} = compile(code);
3433

3534
// Use
3635
console.log(solution(true)(false)); // true
@@ -43,13 +42,10 @@ console.log(TRUE(true)(false)) // true
4342

4443
---
4544

46-
`compile :: String? -> {String: (Term -> Term)}`
45+
`compile :: String -> {String: (Term -> Term)}`
4746

4847
`compile` is the main entry point of the module. Compiles the specified text according the current `config` options, and returns an object binding all defined terms to their corresponding functions.
4948

50-
If called without an argument, will try open a file called `solution.txt` in the same directory, and parse its contents.
51-
52-
5349
---
5450

5551
`config :: {String: String}`
@@ -64,3 +60,23 @@ If called without an argument, will try open a file called `solution.txt` in the
6460
| `numEncoding` | `None` | No number encoding. Use of number literals will cause an error. |
6561
| | `Church`<br>`Scott`<br>`BinaryScott` | Number literals will be automatically converted to corresponding LC terms, according to the encoding chosen. |
6662
| `verbosity` | `Calm`<br>`Concise`<br>`Loquacious`<br>`Verbose` | Controls the amount of information that will be reported during compilation. |
63+
64+
### Container Image
65+
66+
The container image used by the Code Runner is available on [GHCR](https://github.com/codewars/lambda-calculus/pkgs/container/lambda-calculus).
67+
68+
```bash
69+
docker pull ghcr.io/codewars/lambda-calculus:latest
70+
```
71+
72+
#### Building
73+
74+
The image can be built from this repository:
75+
76+
```bash
77+
docker build -t ghcr.io/codewars/lambda-calculus:latest .
78+
```
79+
80+
#### Usage
81+
82+
See [example/](./example/) to learn how to use the image to test locally.

0 commit comments

Comments
 (0)