From 6ea295ae50c53d98a9b799d7c28aeffcdffccb84 Mon Sep 17 00:00:00 2001 From: Paul Sasieta Arana Date: Fri, 25 Oct 2024 14:16:11 +0200 Subject: [PATCH 1/5] Exponentitaion (iterative): Scala implementation --- README.md | 4 ++-- src/scala/Exponentiation.scala | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 src/scala/Exponentiation.scala diff --git a/README.md b/README.md index 15fbb6ec..e780c7e6 100644 --- a/README.md +++ b/README.md @@ -402,8 +402,8 @@ In order to achieve greater coverage and encourage more people to contribute to - - + + diff --git a/src/scala/Exponentiation.scala b/src/scala/Exponentiation.scala new file mode 100644 index 00000000..4279dd34 --- /dev/null +++ b/src/scala/Exponentiation.scala @@ -0,0 +1,9 @@ +def exponentiation(base: Int, exponent: Int): Int = { + (1 to exponent) + .map(_ => base) + .reduce(_ * _) +} + +object Main extends App { + println("5 ^ 3 = " + exponentiation(5, 3)); +} \ No newline at end of file From fdb358ecd32f5a2f981c7f1a5194e9e7b396cebb Mon Sep 17 00:00:00 2001 From: Paul Sasieta Arana Date: Mon, 28 Oct 2024 07:09:20 +0100 Subject: [PATCH 2/5] Linting fixed --- src/scala/Exponentiation.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/scala/Exponentiation.scala b/src/scala/Exponentiation.scala index 4279dd34..84ecdae4 100644 --- a/src/scala/Exponentiation.scala +++ b/src/scala/Exponentiation.scala @@ -1,9 +1,9 @@ def exponentiation(base: Int, exponent: Int): Int = { - (1 to exponent) - .map(_ => base) - .reduce(_ * _) + (1 to exponent) + .map(_ => base) + .reduce(_ * _) } object Main extends App { - println("5 ^ 3 = " + exponentiation(5, 3)); + println("5 ^ 3 = " + exponentiation(5, 3)); } \ No newline at end of file From 75b842d96d4c0f57744554b5d5eb2467070fd6ac Mon Sep 17 00:00:00 2001 From: "Kelvin S. do Prado" Date: Mon, 28 Oct 2024 21:10:35 -0300 Subject: [PATCH 3/5] Update src/scala/Exponentiation.scala --- src/scala/Exponentiation.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scala/Exponentiation.scala b/src/scala/Exponentiation.scala index 84ecdae4..54062c11 100644 --- a/src/scala/Exponentiation.scala +++ b/src/scala/Exponentiation.scala @@ -1,7 +1,7 @@ def exponentiation(base: Int, exponent: Int): Int = { (1 to exponent) - .map(_ => base) - .reduce(_ * _) + .map(_ => base) + .reduce(_ * _) } object Main extends App { From 66f9f94cdc865470209b1bf11fcead8c51f36644 Mon Sep 17 00:00:00 2001 From: "Kelvin S. do Prado" Date: Mon, 28 Oct 2024 21:10:40 -0300 Subject: [PATCH 4/5] Update src/scala/Exponentiation.scala --- src/scala/Exponentiation.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scala/Exponentiation.scala b/src/scala/Exponentiation.scala index 54062c11..12ca02db 100644 --- a/src/scala/Exponentiation.scala +++ b/src/scala/Exponentiation.scala @@ -5,5 +5,5 @@ def exponentiation(base: Int, exponent: Int): Int = { } object Main extends App { - println("5 ^ 3 = " + exponentiation(5, 3)); + println("5 ^ 3 = " + exponentiation(5, 3)) } \ No newline at end of file From 035bf033a57e20f407e88c851957b1563008f7ea Mon Sep 17 00:00:00 2001 From: "Kelvin S. do Prado" Date: Mon, 28 Oct 2024 21:21:05 -0300 Subject: [PATCH 5/5] Remove trailing whitespace --- src/scala/Exponentiation.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scala/Exponentiation.scala b/src/scala/Exponentiation.scala index 12ca02db..0640a121 100644 --- a/src/scala/Exponentiation.scala +++ b/src/scala/Exponentiation.scala @@ -3,7 +3,7 @@ def exponentiation(base: Int, exponent: Int): Int = { .map(_ => base) .reduce(_ * _) } - + object Main extends App { println("5 ^ 3 = " + exponentiation(5, 3)) -} \ No newline at end of file +}