https://github.com/zegl/rules_calculator
A calculator in Bazel - Created for a talk at `bazel build //stockholm/...`
https://github.com/zegl/rules_calculator
Last synced: 9 months ago
JSON representation
A calculator in Bazel - Created for a talk at `bazel build //stockholm/...`
- Host: GitHub
- URL: https://github.com/zegl/rules_calculator
- Owner: zegl
- Created: 2019-08-26T09:44:14.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-08-27T13:19:04.000Z (almost 7 years ago)
- Last Synced: 2025-01-11T04:17:28.370Z (over 1 year ago)
- Language: Python
- Size: 8.79 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rules_calculator
A toy project for learning about Bazel rules, and will be used as the base for a talk at the [bazel build //stockholm/...](https://www.meetup.com/BazelSTHLM) meetup group.
## Documentation
## add
add(name, terms)
Calculates the sum (addition) of the provided numbers.
Example:
```python
# Calculates 3 + 4 + 2, with the output 9
add(
name = "three_plus_four_plus_two",
terms = [
":three",
":four",
":two",
],
)
```
### Attributes
name
Name; required
A unique name for this target.
terms
List of labels; required
The numbers to add
## display
display(name, value)
### Attributes
name
Name; required
A unique name for this target.
value
Label; required
The numbers to print when running this target
## div
div(name, dividend, divisor)
Divides the `dividend` with the `divisor`, and outputs the `qoutient`.
Example:
```python
# Calculates 20 / 5 to return 4
add(
name = "tewnty_div_five",
dividend = ":twenty",
divisor = ":four",
)
```
### Attributes
name
Name; required
A unique name for this target.
dividend
Label; required
divisor
Label; required
## fib
fib(name, n)
### Parameters
name
required.
n
required.
## mul
mul(name, terms)
Calculates the product of the factors.
Example:
```python
# Calculates 3 * 4 * 2, with the output 24
mul(
name = "three_plus_four_plus_two",
terms = [
":three",
":four",
":two",
],
)
```
### Attributes
name
Name; required
A unique name for this target.
terms
List of labels; required
The factors to multiply with each other
## number
number(name, number)
Defines a single static number.
Example:
```python
number(
name = "five",
number = 5,
)
```
### Attributes
name
Name; required
A unique name for this target.
number
Integer; required
The integer to write to the output
## sub
sub(name, subtract, value)
Calculates the difference between two terms.
Example:
```python
# Calculates 20 - 5 to return 15
sub(
name = "twenty_minus_five",
terms = []
value = ":twenty",
subtract = ":five",
)
```
### Attributes
name
Name; required
A unique name for this target.
subtract
Label; required
value
Label; required