From c464059153f6f9d3e99bf024f6e4a7163309828e Mon Sep 17 00:00:00 2001 From: NicklasXYZ Date: Sun, 5 Feb 2023 12:21:13 +0100 Subject: [PATCH] Add cartesian_product example --- src/gleam_community/maths/list.gleam | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/gleam_community/maths/list.gleam b/src/gleam_community/maths/list.gleam index c555b45..fc9b1ae 100644 --- a/src/gleam_community/maths/list.gleam +++ b/src/gleam_community/maths/list.gleam @@ -53,9 +53,9 @@ import gleam/io /// |> should.be_error() /// /// // Trim the list to only the middle part of list -/// [1., 2., 3., 4., 5., 6.] +/// [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] /// |> listx.trim(1, 4) -/// |> should.equal(Ok([2., 3., 4., 5.])) +/// |> should.equal(Ok([2.0, 3.0, 4.0, 5.0])) /// } /// /// @@ -97,7 +97,7 @@ pub fn trim(arr: List(a), min: Int, max: Int) -> Result(List(a), String) { /// /// import gleeunit/should /// import gleam/list -/// import gleam_community/maths/float_list +/// import gleam_community/maths/list as listx /// /// pub fn example () { /// } @@ -126,7 +126,7 @@ pub fn combination(arr: List(a), k: Int) -> List(a) { /// /// import gleeunit/should /// import gleam/list -/// import gleam_community/maths/float_list +/// import gleam_community/maths/list as listx /// /// pub fn example () { /// } @@ -155,9 +155,16 @@ pub fn permutation(arr: List(a)) -> List(a) { /// /// import gleeunit/should /// import gleam/list -/// import gleam_community/maths/float_list +/// import gleam_community/maths/list as listx /// /// pub fn example () { +/// [] +/// |> listx.cartesian_product([]) +/// |> should.equal([]) +/// +/// [1.0, 10.0] +/// |> listx.cartesian_product([1.0, 2.0]) +/// |> should.equal([#(1.0, 1.0), #(1.0, 2.0), #(10.0, 1.0), #(10.0, 2.0)]) /// } /// ///