Initial Commit

This commit is contained in:
2016-08-13 18:20:14 -05:00
commit 50f4a86fd8
408 changed files with 15301 additions and 0 deletions

35
clojure/bob/README.md Normal file
View File

@@ -0,0 +1,35 @@
# Bob
Bob is a lackadaisical teenager. In conversation, his responses are very limited.
Bob answers 'Sure.' if you ask him a question.
He answers 'Whoa, chill out!' if you yell at him.
He says 'Fine. Be that way!' if you address him without actually saying
anything.
He answers 'Whatever.' to anything else.
## Instructions
Run the test file, and fix each of the errors in turn. When you get the
first test to pass, go to the first pending or skipped test, and make
that pass as well. When all of the tests are passing, feel free to
submit.
Remember that passing code is just the first step. The goal is to work
towards a solution that is as readable and expressive as you can make
it.
Please make your solution as general as possible. Good code doesn't just
pass the test suite, it works with any input that fits the
specification.
Have fun!
## Source
Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial. [view source](http://pine.fm/LearnToProgram/?Chapter=06)

48
clojure/bob/bob_test.clj Normal file
View File

@@ -0,0 +1,48 @@
(ns bob-test
(:require [clojure.test :refer :all]))
(load-file "bob.clj")
(deftest responds-to-something
(is (= "Whatever." (bob/response-for "Tom-ay-to, tom-aaaah-to."))))
(deftest responds-to-shouts
(is (= "Whoa, chill out!" (bob/response-for "WATCH OUT!"))))
(deftest responds-to-questions
(is (= "Sure." (bob/response-for "Does this cryogenic chamber make me look fat?"))))
(deftest responds-to-forceful-talking
(is (= "Whatever." (bob/response-for "Let's go make out behind the gym!"))))
(deftest responds-to-acronyms
(is (= "Whatever." (bob/response-for "It's OK if you don't want to go to the DMV."))))
(deftest responds-to-forceful-questions
(is (= "Whoa, chill out!" (bob/response-for "WHAT THE HELL WERE YOU THINKING?"))))
(deftest responds-to-shouting-with-special-characters
(is (= "Whoa, chill out!" (bob/response-for "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"))))
(deftest responds-to-shouting-numbers
(is (= "Whoa, chill out!" (bob/response-for "1, 2, 3 GO!"))))
(deftest responds-to-shouting-with-no-exclamation-mark
(is (= "Whoa, chill out!" (bob/response-for "I HATE YOU"))))
(deftest responds-to-statement-containing-question-mark
(is (= "Whatever." (bob/response-for "Ending with ? means a question."))))
(deftest responds-to-silence
(is (= "Fine. Be that way!" (bob/response-for ""))))
(deftest responds-to-prolonged-silence
(is (= "Fine. Be that way!" (bob/response-for " "))))
(deftest responds-to-only-numbers
(is (= "Whatever." (bob/response-for "1, 2, 3"))))
(deftest responds-to-number-question
(is (= "Sure." (bob/response-for "4?"))))
(run-tests)

6
clojure/bob/project.clj Normal file
View File

@@ -0,0 +1,6 @@
(defproject bob "0.1.0-SNAPSHOT"
:description "bob exercise."
:url "https://github.com/exercism/xclojure/tree/master/bob"
:source-paths [""]
:test-paths [""]
:dependencies [[org.clojure/clojure "1.7.0"]])

1
clojure/current Symbolic link
View File

@@ -0,0 +1 @@
hello-world

View File

@@ -0,0 +1,82 @@
# Hello World
Write a program that greets the user by name, or by saying "Hello, World!" if no name is given.
["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is the traditional first program for beginning programming in a new language.
**Note:** You can skip this exercise by running:
exercism skip $LANGUAGE hello-world
## Specification
The `Hello World!` program will greet me, the caller.
If I tell the program my name is Alice, it will greet me by saying "Hello, Alice!".
If I neglect to give it my name, it will greet me by saying "Hello, World!"
## Test-Driven Development
As programmers mature, they eventually want to test their code.
Here at Exercism we simulate [Test-Driven Development](http://en.wikipedia.org/wiki/Test-driven_development) (TDD), where you write your tests before writing any functionality. The simulation comes in the form of a pre-written test suite, which will signal that you have solved the problem.
It will also provide you with a safety net to explore other solutions without breaking the functionality.
### A typical TDD workflow on Exercism:
1. Run the test file and pick one test that's failing.
2. Write some code to fix the test you picked.
3. Re-run the tests to confirm the test is now passing.
4. Repeat from step 1.
5. [Submit your solution](http://help.exercism.io/submitting-exercises.html).
## Instructions
Submissions are encouraged to be general, within reason. Having said that, it's also important not to over-engineer a solution.
It's important to remember that the goal is to make code as expressive and readable as we can. However, solutions to the hello-world exercise will be not be reviewed by a person, but by rikki- the robot, who will offer an encouraging word.
* * * *
For learning resources and help with installation, refer to the
[Exercism help page][].
To run the tests provided, you will need to install [Leiningen][].
To install Leiningen on Mac OS X using [Homebrew][], run the following command:
brew install leiningen
For help installing on Linux, Windows or without Homebrew see:
[Leiningen installation][].
[Exercism help page]: http://exercism.io/languages/clojure
[Leiningen]: http://leiningen.org
[Homebrew]: http://brew.sh
[Leiningen installation]: https://github.com/technomancy/leiningen#installation
In an exercise directory, create a `src` directory and a file therein to hold
your solution. The name of the file should be the exercise name with dashes `-`
replaced by underscores `_`. For example, if the exercise is called
`hello-world`, name the solution file `hello_world.clj`.
Your resulting file tree should look something like this:
/path/to/hello-world
├── project.clj
├── src
│   └── hello_world.clj
└── test
└── hello_world_test.clj
To run the tests, navigate to the exercise directory and run the following
command:
lein test
## Source
This is a program to introduce users to using Exercism [view source](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)

View File

@@ -0,0 +1,4 @@
(defproject hello-world "0.1.0-SNAPSHOT"
:description "hello-world exercise."
:url "https://github.com/exercism/xclojure/tree/master/hello-world"
:dependencies [[org.clojure/clojure "1.7.0"]])

View File

@@ -0,0 +1,12 @@
(ns hello-world-test
(:require [clojure.test :refer [deftest is]]
hello-world))
(deftest hello-world-test
(is (= "Hello, World!" (hello-world/hello))))
(deftest hello-alice-test
(is (= "Hello, Alice!" (hello-world/hello "Alice"))))
(deftest hello-bob-test
(is (= "Hello, Bob!" (hello-world/hello "Bob"))))