# thekeele's solution

## to Two Fer in the Racket Track

Published at May 02 2019 · 0 comments
Instructions
Test suite
Solution

#### Note:

This exercise has changed since this solution was written.

`Two-fer` or `2-fer` is short for two for one. One for you and one for me.

Given a name, return a string with the message:

``````One for X, one for me.
``````

Where X is the given name.

However, if the name is missing, return the string:

``````One for you, one for me.
``````

Here are some examples:

Name String to return
Alice One for Alice, one for me.
Bob One for Bob, one for me.
One for you, one for me.
Zaphod One for Zaphod, one for me.

For installation and learning resources, refer to the exercism Racket page.

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://github.com/exercism/problem-specifications/issues/757

## Submitting Incomplete Solutions

It's possible to submit an incomplete solution so you can see how others have completed the exercise.

### two-fer-test.rkt

``````#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))``````
``````#lang racket

(provide two-fer)

(define two-fer
(lambda name
(if (empty? name)
"One for you, one for me."
(format "One for ~a, one for me." (first name)))))``````