-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from herwinw/two-fer
Implemented two-fer exercise
- Loading branch information
Showing
5 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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."))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
(define-module (two-fer) | ||
#:export (two-fer)) |