diff --git a/config.json b/config.json index dfd375f2..bf371ed1 100644 --- a/config.json +++ b/config.json @@ -120,6 +120,14 @@ "topics": null, "unlocked_by": null, "uuid": "9460b65d-dc80-4a95-8782-b395d2cc979e" + }, + { + "core": false, + "difficulty": 1, + "slug": "two-fer", + "topics": null, + "unlocked_by": null, + "uuid": "3ecc2d1c-55e0-45c9-ba35-57d7d8cfd51e" } ], "foregone": [], diff --git a/exercises/two-fer/README.md b/exercises/two-fer/README.md new file mode 100644 index 00000000..9b468262 --- /dev/null +++ b/exercises/two-fer/README.md @@ -0,0 +1,10 @@ +`Two-fer` or `2-fer` is short for two for one. One for you and one for me. + +```text +"One for X, one for me." +``` + +When X is a name or "you". + +If the given name is "Alice", the result should be "One for Alice, one for me." +If no name is given, the result should be "One for you, one for me." diff --git a/exercises/two-fer/example.scm b/exercises/two-fer/example.scm new file mode 100644 index 00000000..583b87c9 --- /dev/null +++ b/exercises/two-fer/example.scm @@ -0,0 +1,7 @@ +(define-module (two-fer) + #:export (two-fer)) + +(define two-fer + (lambda* (#:optional name) + (let ((target (or name "you"))) + (string-concatenate (list "One for " target ", one for me."))))) diff --git a/exercises/two-fer/two-fer-test.scm b/exercises/two-fer/two-fer-test.scm new file mode 100644 index 00000000..c815447f --- /dev/null +++ b/exercises/two-fer/two-fer-test.scm @@ -0,0 +1,25 @@ +;; Load SRFI-64 lightweight testing specification +(use-modules (srfi srfi-64)) + +;; Suppress log file output. To write logs, comment out the following line: +(module-define! (resolve-module '(srfi srfi-64)) 'test-log-to-file #f) + +;; Require module +(add-to-load-path (dirname (current-filename))) +(use-modules (two-fer)) + +(test-begin "two-fer") + +(test-assert "no name given" + (equal? (two-fer) + "One for you, one for me.")) + +(test-assert "a name given" + (equal? (two-fer "Alice") + "One for Alice, one for me.")) + +(test-assert "another name given" + (equal? (two-fer "Bob") + "One for Bob, one for me.")) + +(test-end "two-fer") diff --git a/exercises/two-fer/two-fer.scm b/exercises/two-fer/two-fer.scm new file mode 100644 index 00000000..4d2c169a --- /dev/null +++ b/exercises/two-fer/two-fer.scm @@ -0,0 +1,2 @@ +(define-module (two-fer) + #:export (two-fer))