-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Two Fer | ||
|
||
`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." | ||
|
||
|
||
* * * * | ||
|
||
For installation and learning resources, refer to the | ||
[exercism Racket page](http://exercism.io/languages/racket). | ||
|
||
You can run the provided tests through DrRacket, or via the command line. | ||
|
||
To run the test through DrRacket, simply open the test file and click the 'Run' button in the upper right. | ||
|
||
To run the test from the command line, run the test from the exercise directory with the following command: | ||
|
||
``` | ||
raco test two-fer-test.rkt | ||
``` | ||
|
||
which will display the following: | ||
|
||
``` | ||
raco test: (submod "two-fer-test.rkt" test) | ||
2 success(es) 0 failure(s) 0 error(s) 2 test(s) run | ||
0 | ||
2 tests passed | ||
``` | ||
|
||
## Source | ||
|
||
[https://en.wikipedia.org/wiki/Two-fer](https://en.wikipedia.org/wiki/Two-fer) | ||
|
||
## Submitting Incomplete Solutions | ||
It's possible to submit an incomplete solution so you can see how others have completed the exercise. |
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,6 @@ | ||
#lang racket | ||
|
||
(provide two-fer) | ||
|
||
(define (two-fer [name "you"]) | ||
(string-append "One for " name ", 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,22 @@ | ||
#lang racket | ||
|
||
(require "two-fer.rkt") | ||
|
||
(module+ test | ||
(require rackunit rackunit/text-ui) | ||
|
||
(define suite | ||
(test-suite | ||
"two fer tests" | ||
|
||
(test-equal? "no name given" | ||
(two-fer) | ||
"One for you, one for me.") | ||
(test-equal? "a name given" | ||
(two-fer "Alice") | ||
"One for Alice, one for me.") | ||
(test-equal? "another name given" | ||
(two-fer "Bob") | ||
"One for Bob, one for me."))) | ||
|
||
(run-tests suite)) |
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,3 @@ | ||
#lang racket | ||
|
||
(provide two-fer) |