Package Version Hex Docs

Cnocco

Cnocco is a library for computing a possible canoncial cover for a set of functional dependencies.

This is a for-fun project made for the sole purpose of playing with the canoncial cover algorithm introduced at university. I don’t plan on maintaining this project.

Only canonical covers of Ints can be generated, so if you have functional dependencies of other type, you need to parse these into Ints before you can use this library.

Named after “Can(onical) Co(ver) kind of sounds like Cnocco… let’s go with that.”

gleam add cnocco
import gleam/io
import gleam/list
import gleam/string

import cnocco/cover
import cnocco/dependency

pub fn main() -> Nil {
  let assert Ok(deps) =
    cover.from_lists([
      #([1, 2], [3]),
      #([5, 9, 21], [23]),
      #([1, 2, 3, 4, 5], [10]),
      #([18, 20, 22], [25]),
    ])

  deps
  |> cover.from_dependencies()
  |> list.map(dependency.to_string)
  |> string.join("\n")
  |> io.println()

  // Output:
  // {1, 2, 4, 5} -> {10}
  // {18, 20, 22} -> {25}
  // {5, 9, 21} -> {23}
  // {1, 2} -> {3}
}

Development

gleam run   # Run the project
gleam test  # Run the tests
Search Document