Skip to content

Commit

Permalink
adding the utils documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jooaf committed Aug 10, 2024
1 parent 6bc5618 commit eec9003
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/conway/utils.gleam
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import gleam/list

/// Map a function to individual cells in a 2d matrix
pub fn map_2d_matrix_with_state(
matrix: List(List(a)),
map_fn: fn(a, List(List(a))) -> b,
Expand All @@ -9,6 +10,7 @@ pub fn map_2d_matrix_with_state(
})
}

/// Map a function to individual rows in a 2d matrix
pub fn map_2d_matrix(matrix: List(List(a)), map_fn: fn(a) -> b) -> List(List(b)) {
list.map(matrix, fn(row) { list.map(row, map_fn) })
}
Expand All @@ -24,7 +26,7 @@ pub fn list_to_square_matrix(l: List(a), n: Int) -> List(List(a)) {
}
}

/// Used to create a cartesian product for one item with a list
/// Used to create a cartesian product for one item with a list.
/// i.e. 5, [6,7,8] -> [(5,6), (5,7), (5,8)]
pub fn build_product_fn(other: List(Int), x: Int) -> List(#(Int, Int)) {
case other {
Expand Down

0 comments on commit eec9003

Please sign in to comment.