-
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
120 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,48 @@ | ||
# 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." | ||
|
||
|
||
## Elm Installation | ||
|
||
Refer to the [Exercism help page](http://exercism.io/languages/elm) for Elm | ||
installation and learning resources. | ||
|
||
## Writing the Code | ||
|
||
The first time you start an exercise, you'll need to ensure you have the | ||
appropriate dependencies installed. Thankfully, Elm makes that easy for you and | ||
will install dependencies when you try to run tests or build the code. | ||
|
||
Execute the tests with: | ||
|
||
```bash | ||
$ elm-test | ||
``` | ||
|
||
Automatically run tests again when you save changes: | ||
|
||
```bash | ||
$ elm-test --watch | ||
``` | ||
|
||
As you work your way through the test suite, be sure to remove the `skip <|` | ||
calls from each test until you get them all passing! | ||
|
||
## Source | ||
|
||
[https://en.wikipedia.org/wiki/Two-fer](https://en.wikipedia.org/wiki/Two-fer) | ||
|
||
## Submitting Incomplete Solutions | ||
|
||
It is 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,11 @@ | ||
module TwoFer exposing (twoFer) | ||
|
||
|
||
twoFer : Maybe String -> String | ||
twoFer name = | ||
case name of | ||
Just name_ -> | ||
"One for " ++ name_ ++ ", one for me." | ||
|
||
Nothing -> | ||
"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,5 @@ | ||
module TwoFer exposing (twoFer) | ||
|
||
|
||
twoFer name = | ||
Debug.todo "Please implement this function" |
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,19 @@ | ||
{ | ||
"type": "application", | ||
"source-directories": [ | ||
"." | ||
], | ||
"elm-version": "0.19.0", | ||
"dependencies": { | ||
"direct": { | ||
"elm/core": "1.0.0" | ||
}, | ||
"indirect": {} | ||
}, | ||
"test-dependencies": { | ||
"direct": { | ||
"elm-explorations/test": "1.0.0" | ||
}, | ||
"indirect": {} | ||
} | ||
} |
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,27 @@ | ||
module Tests exposing (tests) | ||
|
||
import Expect | ||
import String | ||
import Test exposing (..) | ||
import TwoFer exposing (twoFer) | ||
|
||
|
||
tests : Test | ||
tests = | ||
describe "Two-fer" | ||
[ test "No name given" <| | ||
\() -> | ||
Expect.equal "One for you, one for me." (twoFer Nothing) | ||
|
||
-- Once you get the first test passing, remove the | ||
-- `skip <|` (just leave the comma) on the next two | ||
-- lines to continue! | ||
, skip <| | ||
test "A name given" <| | ||
\() -> | ||
Expect.equal "One for Alice, one for me." (twoFer (Just "Alice")) | ||
, skip <| | ||
test "Another name given" <| | ||
\() -> | ||
Expect.equal "One for Bob, one for me." (twoFer (Just "Bob")) | ||
] |