elixir_prime_table v0.1.0 Table

Functions for generating strings representing tables

Summary

Functions

Returns a string representing a primes multiplication table, given a size. Also accepts an optional padding and a separator

Functions

generate(size, padding \\ 0, separator \\ "|")

Returns a string representing a primes multiplication table, given a size. Also accepts an optional padding and a separator.

Examples

iex> Table.generate(2)
"|   | 2 | 3 |
| 2 | 4 | 6 |
| 3 | 6 | 9 |"

iex> Table.generate(3, 2)
"|      |    2 |    3 |    5 |
|    2 |    4 |    6 |   10 |
|    3 |    6 |    9 |   15 |
|    5 |   10 |   15 |   25 |"

iex> Table.generate(3, 0, "¦")
"¦    ¦  2 ¦  3 ¦  5 ¦
¦  2 ¦  4 ¦  6 ¦ 10 ¦
¦  3 ¦  6 ¦  9 ¦ 15 ¦
¦  5 ¦ 10 ¦ 15 ¦ 25 ¦"