An open API service indexing awesome lists of open source software.

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/...`

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