diff options
author | Santo Cariotti <santo@dcariotti.me> | 2024-12-28 15:19:55 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2024-12-28 15:19:55 +0100 |
commit | b2d3cec552f760a8ff38a224b2b9f9c90dc962aa (patch) | |
tree | 440d8c940a27619e42eb7003724a2989fa286dc2 | |
parent | 78f7e09f3237d1758f9650247b28642b9c5df21e (diff) |
Fix product pair
-rw-r--r-- | co-purchase-analysis/src/main/scala/Main.scala | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/co-purchase-analysis/src/main/scala/Main.scala b/co-purchase-analysis/src/main/scala/Main.scala index 8c3e907..8bd54e6 100644 --- a/co-purchase-analysis/src/main/scala/Main.scala +++ b/co-purchase-analysis/src/main/scala/Main.scala @@ -119,22 +119,11 @@ object CoPurchaseAnalysis { i <- products.indices.toList j <- (i + 1) until products.length } yield { - if (products(i) < products(j)) { - ProductPair(products(i), products(j)) - } else { - ProductPair(products(j), products(i)) - } + val (p1, p2) = + if (products(i) < products(j)) (products(i), products(j)) + else (products(j), products(i)) + ProductPair(p1, p2) } - // val sortedProducts = products.sorted - // for { - // i <- sortedProducts.indices.toList - // j <- (i + 1) until sortedProducts.length - // } yield { - // val product1 = sortedProducts(i) - // val product2 = sortedProducts(j) - // - // ProductPair(product1, product2) - // } } /** Processes the order data to generate co-purchase statistics. |