aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-105/abigail/README.md1
-rw-r--r--challenge-105/abigail/scheme/ch-1.scm31
2 files changed, 32 insertions, 0 deletions
diff --git a/challenge-105/abigail/README.md b/challenge-105/abigail/README.md
index b3f76aba43..c503be0687 100644
--- a/challenge-105/abigail/README.md
+++ b/challenge-105/abigail/README.md
@@ -27,6 +27,7 @@ Output: 2.02
* [Perl](perl/ch-1.pl)
* [Python](python/ch-1.py)
* [Ruby](ruby/ch-1.rb)
+* [Scheme](scheme/ch-1.scm)
* [SQL](sql/ch-1.sql)
### Blog
diff --git a/challenge-105/abigail/scheme/ch-1.scm b/challenge-105/abigail/scheme/ch-1.scm
new file mode 100644
index 0000000000..41e97c6985
--- /dev/null
+++ b/challenge-105/abigail/scheme/ch-1.scm
@@ -0,0 +1,31 @@
+;;;
+;;; See ../README.md
+;;;
+
+;;;
+;;; Run as: guile --no-auto-compile ch-1.scm < input-file
+;;;
+;;; Input will consist of lines; each line will have two numbers, N and k
+;;; N > 0, k > 0. For each line of input, we output a line with the Nth
+;;; root of k.
+;;;
+;;; We're not doing any input validations; we're assuming it's correct.
+;;;
+
+;;;
+;;; To find the Nth root of a number k, we just raise k to the power 1/N.
+;;;
+
+(use-modules (ice-9 format))
+
+(define (nthroot)
+ (define N (read))
+ (if (not (eof-object? N))
+ (begin
+ (format #t "~f\n" (expt (read) (/ 1 N)))
+ (nthroot)
+ )
+ )
+)
+
+(nthroot)