From b2d3cec552f760a8ff38a224b2b9f9c90dc962aa Mon Sep 17 00:00:00 2001
From: Santo Cariotti <santo@dcariotti.me>
Date: Sat, 28 Dec 2024 15:19:55 +0100
Subject: Fix product pair

---
 co-purchase-analysis/src/main/scala/Main.scala | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

(limited to 'co-purchase-analysis/src/main/scala')

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.
-- 
cgit v1.2.3-18-g5258