trackler 1.0.0 → 1.0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -0
- data/CHANGELOG.md +9 -1
- data/README.md +10 -0
- data/common/CONTRIBUTING.md +50 -2
- data/common/exercises/alphametics/canonical-data.json +10 -10
- data/common/exercises/markdown/canonical-data.json +4 -4
- data/common/exercises/pov/canonical-data.json +356 -0
- data/lib/trackler/version.rb +1 -1
- data/trackler.gemspec +1 -2
- data/tracks/c/config.json +11 -1
- data/tracks/c/exercises/binary-search/makefile +16 -0
- data/tracks/c/exercises/binary-search/src/example.c +21 -0
- data/tracks/c/exercises/binary-search/src/example.h +8 -0
- data/tracks/c/exercises/binary-search/test/test_binary_search.c +99 -0
- data/tracks/c/exercises/binary-search/test/vendor/unity.c +1300 -0
- data/tracks/c/exercises/binary-search/test/vendor/unity.h +274 -0
- data/tracks/c/exercises/binary-search/test/vendor/unity_internals.h +701 -0
- data/tracks/clojure/config.json +3 -2
- data/tracks/clojure/exercises/bank-account/project.clj +4 -0
- data/tracks/clojure/exercises/bank-account/src/example.clj +17 -0
- data/tracks/clojure/exercises/bank-account/test/bank_account_test.clj +44 -0
- data/tracks/clojure/exercises/isogram/project.clj +4 -0
- data/tracks/clojure/exercises/isogram/src/example.clj +5 -0
- data/tracks/clojure/exercises/isogram/test/isogram_test.clj +17 -0
- data/tracks/csharp/config.json +27 -87
- data/tracks/csharp/exercises/exercises.csproj +265 -1
- data/tracks/csharp/exercises/grep/Example.cs +114 -0
- data/tracks/csharp/exercises/grep/GrepTest.cs +376 -0
- data/tracks/csharp/exercises/paket.references +2 -1
- data/tracks/csharp/exercises/poker/Example.cs +96 -0
- data/tracks/csharp/exercises/poker/PokerTest.cs +171 -0
- data/tracks/csharp/exercises/sgf-parsing/Example.cs +61 -0
- data/tracks/csharp/exercises/sgf-parsing/SgfParsing.cs +13 -0
- data/tracks/csharp/exercises/sgf-parsing/SgfParsingTest.cs +158 -0
- data/tracks/csharp/paket.dependencies +2 -1
- data/tracks/csharp/paket.lock +72 -0
- data/tracks/ecmascript/exercises/simple-cipher/simple-cipher.spec.js +1 -1
- data/tracks/elisp/config.json +6 -1
- data/tracks/elisp/exercises/etl/etl-test.el +90 -0
- data/tracks/elisp/exercises/etl/etl.el +9 -0
- data/tracks/elisp/exercises/etl/example.el +22 -0
- data/tracks/elisp/exercises/nucleotide-count/example.el +19 -0
- data/tracks/elisp/exercises/nucleotide-count/nucleotide-count-test.el +34 -0
- data/tracks/elisp/exercises/nucleotide-count/nucleotide-count.el +9 -0
- data/tracks/elisp/exercises/perfect-numbers/example.el +28 -0
- data/tracks/elisp/exercises/perfect-numbers/perfect-numbers-test.el +24 -0
- data/tracks/elisp/exercises/perfect-numbers/perfect-numbers.el +10 -0
- data/tracks/elisp/exercises/roman-numerals/example.el +36 -0
- data/tracks/elisp/exercises/roman-numerals/roman-numerals-test.el +30 -0
- data/tracks/elisp/exercises/roman-numerals/roman-numerals.el +10 -0
- data/tracks/elisp/exercises/word-count/example.el +18 -0
- data/tracks/elisp/exercises/word-count/word-count-test.el +64 -0
- data/tracks/elisp/exercises/word-count/word-count.el +9 -0
- data/tracks/elixir/README.md +4 -4
- data/tracks/elixir/SETUP.md +3 -3
- data/tracks/elixir/docs/TESTS.md +3 -3
- data/tracks/elixir/exercises/accumulate/accumulate_test.exs +7 -7
- data/tracks/elixir/exercises/acronym/acronym_test.exs +5 -5
- data/tracks/elixir/exercises/allergies/allergies_test.exs +13 -13
- data/tracks/elixir/exercises/anagram/anagram_test.exs +12 -12
- data/tracks/elixir/exercises/atbash-cipher/atbash_cipher_test.exs +9 -9
- data/tracks/elixir/exercises/bank-account/bank_account_test.exs +5 -5
- data/tracks/elixir/exercises/beer-song/beer_song_test.exs +6 -6
- data/tracks/elixir/exercises/binary-search/binary_search_test.exs +7 -7
- data/tracks/elixir/exercises/binary/binary_test.exs +13 -13
- data/tracks/elixir/exercises/bob/bob_test.exs +15 -15
- data/tracks/elixir/exercises/bowling/bowling_test.exs +18 -18
- data/tracks/elixir/exercises/bracket-push/bracket_push_test.exs +12 -12
- data/tracks/elixir/exercises/change/change_test.exs +7 -7
- data/tracks/elixir/exercises/connect/connect_test.exs +9 -9
- data/tracks/elixir/exercises/crypto-square/crypto_square_test.exs +7 -7
- data/tracks/elixir/exercises/custom-set/custom_set_test.exs +11 -11
- data/tracks/elixir/exercises/diamond/diamond_test.exs +4 -4
- data/tracks/elixir/exercises/difference-of-squares/difference_of_squares_test.exs +10 -10
- data/tracks/elixir/exercises/dot-dsl/dot_dsl_test.exs +17 -17
- data/tracks/elixir/exercises/etl/etl_test.exs +5 -5
- data/tracks/elixir/exercises/flatten-array/flatten_array_test.exs +6 -6
- data/tracks/elixir/exercises/forth/forth_test.exs +16 -16
- data/tracks/elixir/exercises/gigasecond/gigasecond_test.exs +5 -5
- data/tracks/elixir/exercises/grade-school/grade_school_test.exs +6 -6
- data/tracks/elixir/exercises/grains/grains_test.exs +9 -9
- data/tracks/elixir/exercises/hamming/hamming_test.exs +6 -6
- data/tracks/elixir/exercises/hello-world/hello_world_test.exs +3 -3
- data/tracks/elixir/exercises/hexadecimal/hexadecimal_test.exs +11 -11
- data/tracks/elixir/exercises/isogram/isogram_test.exs +10 -10
- data/tracks/elixir/exercises/kindergarten-garden/garden_test.exs +7 -7
- data/tracks/elixir/exercises/largest-series-product/largest_series_product_test.exs +17 -17
- data/tracks/elixir/exercises/leap/leap_test.exs +5 -5
- data/tracks/elixir/exercises/list-ops/list_ops_test.exs +26 -26
- data/tracks/elixir/exercises/luhn/luhn_test.exs +7 -7
- data/tracks/elixir/exercises/markdown/markdown_test.exs +10 -10
- data/tracks/elixir/exercises/meetup/meetup_test.exs +92 -92
- data/tracks/elixir/exercises/minesweeper/minesweeper_test.exs +8 -8
- data/tracks/elixir/exercises/nth-prime/nth_prime_test.exs +6 -6
- data/tracks/elixir/exercises/nucleotide-count/example.exs +0 -5
- data/tracks/elixir/exercises/nucleotide-count/nucleotide_count_test.exs +7 -7
- data/tracks/elixir/exercises/palindrome-products/palindrome_products_test.exs +6 -6
- data/tracks/elixir/exercises/pangram/pangram_test.exs +11 -11
- data/tracks/elixir/exercises/parallel-letter-frequency/parallel_letter_frequency_test.exs +10 -10
- data/tracks/elixir/exercises/pascals-triangle/pascals_triangle_test.exs +7 -7
- data/tracks/elixir/exercises/phone-number/phone_number_test.exs +10 -10
- data/tracks/elixir/exercises/prime-factors/prime_factors_test.exs +13 -13
- data/tracks/elixir/exercises/pythagorean-triplet/pythagorean_triplet_test.exs +8 -8
- data/tracks/elixir/exercises/queen-attack/queen_attack_test.exs +16 -16
- data/tracks/elixir/exercises/rail-fence-cipher/rail_fence_cipher_test.exs +13 -13
- data/tracks/elixir/exercises/raindrops/raindrops_test.exs +17 -17
- data/tracks/elixir/exercises/rna-transcription/rna_transcription_test.exs +6 -6
- data/tracks/elixir/exercises/robot-simulator/robot_simulator_test.exs +6 -6
- data/tracks/elixir/exercises/roman-numerals/roman_numerals_test.exs +19 -19
- data/tracks/elixir/exercises/run-length-encoding/rle_test.exs +6 -6
- data/tracks/elixir/exercises/saddle-points/saddle_points_test.exs +11 -11
- data/tracks/elixir/exercises/scrabble-score/scrabble_score_test.exs +9 -9
- data/tracks/elixir/exercises/sieve/sieve_test.exs +3 -3
- data/tracks/elixir/exercises/space-age/space_age_test.exs +9 -9
- data/tracks/elixir/exercises/sublist/sublist_test.exs +20 -20
- data/tracks/elixir/exercises/sum-of-multiples/sum_of_multiples_test.exs +11 -11
- data/tracks/elixir/exercises/test_helper.exs +1 -1
- data/tracks/elixir/exercises/triangle/triangle_test.exs +16 -16
- data/tracks/elixir/exercises/word-count/word_count_test.exs +9 -9
- data/tracks/elixir/exercises/wordy/wordy_test.exs +16 -16
- data/tracks/elixir/exercises/zipper/zipper_test.exs +13 -13
- data/tracks/fsharp/build.fsx +2 -7
- data/tracks/fsharp/config.json +0 -104
- data/tracks/fsharp/exercises/grep/GrepTest.fs +7 -1
- data/tracks/go/config.json +1 -0
- data/tracks/go/exercises/acronym/acronym_test.go +36 -0
- data/tracks/go/exercises/acronym/example.go +21 -0
- data/tracks/go/exercises/palindrome-products/example.go +2 -0
- data/tracks/go/exercises/palindrome-products/palindrome_products_test.go +10 -0
- data/tracks/go/exercises/phone-number/example.go +2 -0
- data/tracks/go/exercises/phone-number/phone_number_test.go +44 -27
- data/tracks/go/exercises/robot-simulator/defs.go +6 -6
- data/tracks/go/exercises/robot-simulator/example.go +22 -22
- data/tracks/go/exercises/robot-simulator/robot_simulator_step2_test.go +28 -28
- data/tracks/go/exercises/robot-simulator/robot_simulator_step3_test.go +75 -76
- data/tracks/go/exercises/robot-simulator/robot_simulator_test.go +10 -4
- data/tracks/haskell/exercises/anagram/HINTS.md +22 -0
- data/tracks/haskell/exercises/anagram/package.yaml +3 -0
- data/tracks/haskell/exercises/anagram/src/Example.hs +10 -7
- data/tracks/haskell/exercises/anagram/test/Tests.hs +9 -3
- data/tracks/haskell/exercises/beer-song/HINTS.md +18 -0
- data/tracks/haskell/exercises/beer-song/src/Beer.hs +301 -3
- data/tracks/haskell/exercises/beer-song/src/Example.hs +5 -3
- data/tracks/haskell/exercises/beer-song/test/Tests.hs +332 -23
- data/tracks/haskell/exercises/crypto-square/src/CryptoSquare.hs +3 -17
- data/tracks/haskell/exercises/crypto-square/src/Example.hs +12 -20
- data/tracks/haskell/exercises/crypto-square/test/Tests.hs +46 -86
- data/tracks/haskell/exercises/leap/HINTS.md +11 -0
- data/tracks/haskell/exercises/leap/src/LeapYear.hs +1 -0
- data/tracks/java/exercises/pangram/src/test/java/PangramTest.java +34 -4
- data/tracks/lua/exercises/pov/pov_spec.lua +0 -13
- data/tracks/mips/docs/ABOUT.md +1 -1
- data/tracks/objective-c/config.json +225 -0
- data/tracks/objective-c/exercises/largest-series-product/LargestSeriesProductExample.h +8 -0
- data/tracks/objective-c/exercises/largest-series-product/LargestSeriesProductExample.m +63 -0
- data/tracks/objective-c/exercises/largest-series-product/LargestSeriesProductTest.m +84 -0
- data/tracks/objective-c/xcodeProject/ObjectiveC.xcodeproj/project.pbxproj +18 -0
- data/tracks/ocaml/.travis-ci.sh +23 -0
- data/tracks/ocaml/.travis.yml +5 -1
- data/tracks/ocaml/Makefile +41 -0
- data/tracks/ocaml/config.json +18 -0
- data/tracks/ocaml/exercises/anagram/Makefile +1 -0
- data/tracks/ocaml/exercises/beer-song/Makefile +1 -0
- data/tracks/ocaml/exercises/beer-song/{beer.mli → beer_song.mli} +0 -0
- data/tracks/ocaml/exercises/beer-song/example.ml +1 -1
- data/tracks/ocaml/exercises/beer-song/test.ml +7 -6
- data/tracks/ocaml/exercises/bob/Makefile +1 -0
- data/tracks/ocaml/exercises/bowling/Makefile +1 -0
- data/tracks/ocaml/exercises/custom-set/Makefile +1 -0
- data/tracks/ocaml/exercises/difference-of-squares/.merlin +5 -0
- data/tracks/ocaml/exercises/difference-of-squares/Makefile +11 -0
- data/tracks/ocaml/exercises/difference-of-squares/difference_of_squares.mli +8 -0
- data/tracks/ocaml/exercises/difference-of-squares/example.ml +21 -0
- data/tracks/ocaml/exercises/difference-of-squares/test.ml +32 -0
- data/tracks/ocaml/exercises/grade-school/Makefile +1 -0
- data/tracks/ocaml/exercises/grade-school/{school.mli → grade_school.mli} +0 -0
- data/tracks/ocaml/exercises/grade-school/test.ml +27 -27
- data/tracks/ocaml/exercises/hamming/Makefile +1 -0
- data/tracks/ocaml/exercises/hangman/Makefile +1 -0
- data/tracks/ocaml/exercises/hello-world/Makefile +1 -1
- data/tracks/ocaml/exercises/hello-world/{hello.ml → hello_world.ml} +0 -0
- data/tracks/ocaml/exercises/hello-world/{hello.mli → hello_world.mli} +0 -0
- data/tracks/ocaml/exercises/hello-world/test.ml +1 -1
- data/tracks/ocaml/exercises/hexadecimal/Makefile +1 -0
- data/tracks/ocaml/exercises/leap/Makefile +1 -1
- data/tracks/ocaml/exercises/list-ops/Makefile +1 -0
- data/tracks/ocaml/exercises/luhn/Makefile +1 -0
- data/tracks/ocaml/exercises/minesweeper/Makefile +1 -0
- data/tracks/ocaml/exercises/nucleotide-count/Makefile +1 -0
- data/tracks/ocaml/exercises/nucleotide-count/{dna.mli → nucleotide_count.mli} +0 -0
- data/tracks/ocaml/exercises/nucleotide-count/test.ml +7 -7
- data/tracks/ocaml/exercises/phone-number/Makefile +1 -0
- data/tracks/ocaml/exercises/phone-number/{phone.mli → phone_number.mli} +0 -0
- data/tracks/ocaml/exercises/phone-number/test.ml +10 -10
- data/tracks/ocaml/exercises/point-mutations/Makefile +8 -0
- data/tracks/ocaml/exercises/point-mutations/example.ml +0 -0
- data/tracks/ocaml/exercises/prime-factors/Makefile +1 -0
- data/tracks/ocaml/exercises/raindrops/.merlin +5 -0
- data/tracks/ocaml/exercises/raindrops/Makefile +11 -0
- data/tracks/ocaml/exercises/raindrops/example.ml +11 -0
- data/tracks/ocaml/exercises/raindrops/raindrops.mli +7 -0
- data/tracks/ocaml/exercises/raindrops/test.ml +48 -0
- data/tracks/ocaml/exercises/rna-transcription/Makefile +1 -0
- data/tracks/ocaml/exercises/rna-transcription/{dna.mli → rna_transcription.mli} +0 -0
- data/tracks/ocaml/exercises/rna-transcription/test.ml +6 -6
- data/tracks/ocaml/exercises/roman-numerals/Makefile +1 -0
- data/tracks/ocaml/exercises/say/.gitignore +1 -0
- data/tracks/ocaml/exercises/say/.merlin +5 -0
- data/tracks/ocaml/exercises/say/Makefile +11 -0
- data/tracks/ocaml/exercises/say/example.ml +52 -0
- data/tracks/ocaml/exercises/say/say.mli +8 -0
- data/tracks/ocaml/exercises/say/test.ml +65 -0
- data/tracks/ocaml/exercises/space-age/Makefile +1 -0
- data/tracks/ocaml/exercises/word-count/Makefile +1 -0
- data/tracks/ocaml/exercises/word-count/example.ml +1 -1
- data/tracks/ocaml/exercises/zipper/HINT.md +5 -6
- data/tracks/ocaml/exercises/zipper/Makefile +1 -0
- data/tracks/ocaml/exercises/zipper/example.ml +2 -2
- data/tracks/ocaml/exercises/zipper/tree.ml +1 -1
- data/tracks/php/config.json +7 -1
- data/tracks/php/exercises/variable-length-quantity/example.php +56 -0
- data/tracks/php/exercises/variable-length-quantity/variable-length-quantity_test.php +149 -0
- data/tracks/python/config.json +1 -1
- data/tracks/ruby/.rubocop.yml +1915 -26
- data/tracks/ruby/bin/generate-acronym +7 -0
- data/tracks/ruby/bin/generate-nth-prime +7 -0
- data/tracks/ruby/config.json +482 -0
- data/tracks/ruby/exercises/acronym/.version +1 -0
- data/tracks/ruby/exercises/acronym/acronym_test.rb +45 -21
- data/tracks/ruby/exercises/acronym/example.rb +1 -1
- data/tracks/ruby/exercises/acronym/example.tt +19 -0
- data/tracks/ruby/exercises/anagram/anagram_test.rb +1 -1
- data/tracks/ruby/exercises/nth-prime/.version +1 -0
- data/tracks/ruby/exercises/nth-prime/example.rb +4 -0
- data/tracks/ruby/exercises/nth-prime/example.tt +23 -0
- data/tracks/ruby/exercises/nth-prime/nth_prime_test.rb +33 -10
- data/tracks/ruby/exercises/raindrops/.version +1 -1
- data/tracks/ruby/exercises/raindrops/example.rb +1 -1
- data/tracks/ruby/exercises/raindrops/raindrops_test.rb +20 -5
- data/tracks/ruby/lib/acronym_cases.rb +19 -0
- data/tracks/ruby/lib/generator.rb +3 -2
- data/tracks/ruby/lib/nth_prime_cases.rb +23 -0
- data/tracks/ruby/lib/raindrop_cases.rb +1 -1
- data/tracks/rust/README.md +1 -1
- data/tracks/scala/exercises/leap/src/test/scala/leap_test.scala +10 -0
- data/tracks/scala/exercises/prime-factors/example.scala +2 -5
- data/tracks/scala/exercises/prime-factors/src/test/scala/primefactors_test.scala +11 -13
- data/tracks/scheme/{anagram → exercises/anagram}/anagram-test.scm +0 -0
- data/tracks/scheme/{anagram → exercises/anagram}/anagram.scm +0 -0
- data/tracks/scheme/{anagram → exercises/anagram}/example.scm +0 -0
- data/tracks/scheme/{bob → exercises/bob}/bob-test.scm +0 -0
- data/tracks/scheme/{bob → exercises/bob}/bob.scm +0 -0
- data/tracks/scheme/{bob → exercises/bob}/example.scm +0 -0
- data/tracks/scheme/{difference-of-squares → exercises/difference-of-squares}/difference-of-squares-test.scm +0 -0
- data/tracks/scheme/{difference-of-squares → exercises/difference-of-squares}/example.scm +0 -0
- data/tracks/scheme/{difference-of-squares → exercises/difference-of-squares}/squares.scm +0 -0
- data/tracks/scheme/{grains → exercises/grains}/example.scm +0 -0
- data/tracks/scheme/{grains → exercises/grains}/grains-test.scm +0 -0
- data/tracks/scheme/{grains → exercises/grains}/grains.scm +0 -0
- data/tracks/scheme/{hamming → exercises/hamming}/example.scm +0 -0
- data/tracks/scheme/{hamming → exercises/hamming}/hamming-test.scm +0 -0
- data/tracks/scheme/{hamming → exercises/hamming}/hamming.scm +0 -0
- data/tracks/scheme/{hello-world → exercises/hello-world}/example.scm +0 -0
- data/tracks/scheme/{hello-world → exercises/hello-world}/hello-world-test.scm +0 -0
- data/tracks/scheme/{hello-world → exercises/hello-world}/hello-world.scm +0 -0
- data/tracks/scheme/{leap → exercises/leap}/example.scm +0 -0
- data/tracks/scheme/{leap → exercises/leap}/leap-test.scm +0 -0
- data/tracks/scheme/{leap → exercises/leap}/leap-year.scm +0 -0
- data/tracks/scheme/{list-ops → exercises/list-ops}/example.scm +0 -0
- data/tracks/scheme/{list-ops → exercises/list-ops}/list-ops-test.scm +0 -0
- data/tracks/scheme/{list-ops → exercises/list-ops}/list-ops.scm +0 -0
- data/tracks/scheme/{nucleotide-count → exercises/nucleotide-count}/example.scm +0 -0
- data/tracks/scheme/{nucleotide-count → exercises/nucleotide-count}/nucleotide-count-test.scm +0 -0
- data/tracks/scheme/{nucleotide-count → exercises/nucleotide-count}/nucleotide-count.scm +0 -0
- data/tracks/scheme/{phone-number → exercises/phone-number}/example.scm +0 -0
- data/tracks/scheme/{phone-number → exercises/phone-number}/phone-number-test.scm +0 -0
- data/tracks/scheme/{phone-number → exercises/phone-number}/phone-number.scm +0 -0
- data/tracks/scheme/{raindrops → exercises/raindrops}/example.scm +0 -0
- data/tracks/scheme/{raindrops → exercises/raindrops}/raindrops-test.scm +0 -0
- data/tracks/scheme/{raindrops → exercises/raindrops}/raindrops.scm +0 -0
- data/tracks/scheme/{rna-transcription → exercises/rna-transcription}/dna.scm +0 -0
- data/tracks/scheme/{rna-transcription → exercises/rna-transcription}/example.scm +0 -0
- data/tracks/scheme/{rna-transcription → exercises/rna-transcription}/rna-transcription-test.scm +0 -0
- data/tracks/scheme/{robot-name → exercises/robot-name}/example.scm +0 -0
- data/tracks/scheme/{robot-name → exercises/robot-name}/robot-name-test.scm +0 -0
- data/tracks/scheme/{robot-name → exercises/robot-name}/robot.scm +0 -0
- metadata +125 -64
@@ -25,16 +25,22 @@ import (
|
|
25
25
|
"testing"
|
26
26
|
)
|
27
27
|
|
28
|
+
const targetTestVersion = 3
|
29
|
+
|
28
30
|
func TestStep1(t *testing.T) {
|
31
|
+
|
32
|
+
if testVersion != targetTestVersion {
|
33
|
+
t.Fatalf("Found testVersion = %v, want %v", testVersion, targetTestVersion)
|
34
|
+
}
|
29
35
|
want := func(x, y int, dir Dir) {
|
30
36
|
_, _, line, _ := runtime.Caller(1)
|
31
|
-
if X != x || Y != y {
|
37
|
+
if Step1Robot.X != x || Step1Robot.Y != y {
|
32
38
|
t.Fatalf("(from line %d) robot at = %d, %d. Want %d, %d.",
|
33
|
-
line, X, Y, x, y)
|
39
|
+
line, Step1Robot.X, Step1Robot.Y, x, y)
|
34
40
|
}
|
35
|
-
if
|
41
|
+
if Step1Robot.Dir != dir {
|
36
42
|
t.Fatalf("(from line %d) robot facing %v, want %v.",
|
37
|
-
line,
|
43
|
+
line, Step1Robot.Dir, dir)
|
38
44
|
}
|
39
45
|
}
|
40
46
|
want(0, 0, N)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
## Hints
|
2
|
+
|
3
|
+
To complete this exercise you need to implement the function `anagramsFor`,
|
4
|
+
that takes a *word* and a group of *words*, returning the ones that are
|
5
|
+
anagrams of the given *word*.
|
6
|
+
|
7
|
+
If it is your first time solving this exercise, it is recommended that you
|
8
|
+
stick to the provided signature:
|
9
|
+
|
10
|
+
```haskell
|
11
|
+
anagramsFor :: String -> [String] -> [String]
|
12
|
+
```
|
13
|
+
|
14
|
+
Later, it may be a good idea to revisit this problem and play with other data
|
15
|
+
types and libraries:
|
16
|
+
|
17
|
+
- `Text`, from package *text*.
|
18
|
+
- `Sequence` and `Set`, from package *containers*.
|
19
|
+
- `MultiSet`, from package *multiset*
|
20
|
+
|
21
|
+
The test suite was intentionally designed to accept almost any type signature
|
22
|
+
that makes sense, so you are encouraged to find the one you think is the best.
|
@@ -1,10 +1,13 @@
|
|
1
1
|
module Anagram (anagramsFor) where
|
2
|
-
import Data.List (sort)
|
3
|
-
import Data.Char (toLower)
|
4
2
|
|
5
|
-
|
6
|
-
|
3
|
+
import Data.Function (on)
|
4
|
+
import Data.MultiSet (fromList)
|
5
|
+
import Data.Set (Set, filter)
|
6
|
+
import Data.Text (Text, toLower, unpack)
|
7
|
+
import Prelude hiding (filter)
|
8
|
+
|
9
|
+
anagramsFor :: Text -> Set Text -> Set Text
|
10
|
+
anagramsFor x = filter (\w -> x `isDistinctOf` w && x `isAnagramOf` w)
|
7
11
|
where
|
8
|
-
|
9
|
-
(
|
10
|
-
isAnagram (w, s) = nw /= w && sw == s
|
12
|
+
isDistinctOf = (/=) `on` toLower
|
13
|
+
isAnagramOf = (==) `on` fromList . unpack . toLower
|
@@ -1,7 +1,8 @@
|
|
1
1
|
{-# LANGUAGE RecordWildCards #-}
|
2
2
|
|
3
3
|
import Data.Foldable (for_)
|
4
|
-
import
|
4
|
+
import GHC.Exts (fromList, toList)
|
5
|
+
import Test.Hspec (Spec, describe, it, shouldMatchList)
|
5
6
|
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)
|
6
7
|
|
7
8
|
import Anagram (anagramsFor)
|
@@ -14,9 +15,14 @@ specs = describe "anagram" $
|
|
14
15
|
describe "anagramsFor" $ for_ cases test
|
15
16
|
where
|
16
17
|
|
17
|
-
test Case{..} = it description $ expression `
|
18
|
+
test Case{..} = it description $ expression `shouldMatchList` expected
|
18
19
|
where
|
19
|
-
expression =
|
20
|
+
expression = map toList
|
21
|
+
. toList
|
22
|
+
. anagramsFor (fromList subject)
|
23
|
+
. fromList
|
24
|
+
. map fromList
|
25
|
+
$ candidates
|
20
26
|
|
21
27
|
-- Test cases adapted from `exercism/x-common/anagrams.json` on 2016-07-25.
|
22
28
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
## Hints
|
2
|
+
|
3
|
+
This exercise is about [code refactoring](https://en.wikipedia.org/wiki/Refactoring),
|
4
|
+
so we are providing you with a solution that already passes the tests.
|
5
|
+
|
6
|
+
The challenge is to rewrite it until you are proud of it, and learn
|
7
|
+
something in the process.
|
8
|
+
|
9
|
+
If you don't know where to start, here are some ideas:
|
10
|
+
|
11
|
+
- Try to reduce repetition to a minimum.
|
12
|
+
- Try to make the code readable.
|
13
|
+
|
14
|
+
Take your time.
|
15
|
+
|
16
|
+
Change one thing at a time and check if your solution still passes the tests.
|
17
|
+
|
18
|
+
Have fun!
|
@@ -1,5 +1,303 @@
|
|
1
|
-
module Beer (
|
1
|
+
module Beer (song) where
|
2
2
|
|
3
|
-
|
3
|
+
song :: String
|
4
|
+
song = "99 bottles of beer on the wall, 99 bottles of beer.\n\
|
5
|
+
\Take one down and pass it around, 98 bottles of beer on the wall.\n\
|
6
|
+
\\n\
|
7
|
+
\98 bottles of beer on the wall, 98 bottles of beer.\n\
|
8
|
+
\Take one down and pass it around, 97 bottles of beer on the wall.\n\
|
9
|
+
\\n\
|
10
|
+
\97 bottles of beer on the wall, 97 bottles of beer.\n\
|
11
|
+
\Take one down and pass it around, 96 bottles of beer on the wall.\n\
|
12
|
+
\\n\
|
13
|
+
\96 bottles of beer on the wall, 96 bottles of beer.\n\
|
14
|
+
\Take one down and pass it around, 95 bottles of beer on the wall.\n\
|
15
|
+
\\n\
|
16
|
+
\95 bottles of beer on the wall, 95 bottles of beer.\n\
|
17
|
+
\Take one down and pass it around, 94 bottles of beer on the wall.\n\
|
18
|
+
\\n\
|
19
|
+
\94 bottles of beer on the wall, 94 bottles of beer.\n\
|
20
|
+
\Take one down and pass it around, 93 bottles of beer on the wall.\n\
|
21
|
+
\\n\
|
22
|
+
\93 bottles of beer on the wall, 93 bottles of beer.\n\
|
23
|
+
\Take one down and pass it around, 92 bottles of beer on the wall.\n\
|
24
|
+
\\n\
|
25
|
+
\92 bottles of beer on the wall, 92 bottles of beer.\n\
|
26
|
+
\Take one down and pass it around, 91 bottles of beer on the wall.\n\
|
27
|
+
\\n\
|
28
|
+
\91 bottles of beer on the wall, 91 bottles of beer.\n\
|
29
|
+
\Take one down and pass it around, 90 bottles of beer on the wall.\n\
|
30
|
+
\\n\
|
31
|
+
\90 bottles of beer on the wall, 90 bottles of beer.\n\
|
32
|
+
\Take one down and pass it around, 89 bottles of beer on the wall.\n\
|
33
|
+
\\n\
|
34
|
+
\89 bottles of beer on the wall, 89 bottles of beer.\n\
|
35
|
+
\Take one down and pass it around, 88 bottles of beer on the wall.\n\
|
36
|
+
\\n\
|
37
|
+
\88 bottles of beer on the wall, 88 bottles of beer.\n\
|
38
|
+
\Take one down and pass it around, 87 bottles of beer on the wall.\n\
|
39
|
+
\\n\
|
40
|
+
\87 bottles of beer on the wall, 87 bottles of beer.\n\
|
41
|
+
\Take one down and pass it around, 86 bottles of beer on the wall.\n\
|
42
|
+
\\n\
|
43
|
+
\86 bottles of beer on the wall, 86 bottles of beer.\n\
|
44
|
+
\Take one down and pass it around, 85 bottles of beer on the wall.\n\
|
45
|
+
\\n\
|
46
|
+
\85 bottles of beer on the wall, 85 bottles of beer.\n\
|
47
|
+
\Take one down and pass it around, 84 bottles of beer on the wall.\n\
|
48
|
+
\\n\
|
49
|
+
\84 bottles of beer on the wall, 84 bottles of beer.\n\
|
50
|
+
\Take one down and pass it around, 83 bottles of beer on the wall.\n\
|
51
|
+
\\n\
|
52
|
+
\83 bottles of beer on the wall, 83 bottles of beer.\n\
|
53
|
+
\Take one down and pass it around, 82 bottles of beer on the wall.\n\
|
54
|
+
\\n\
|
55
|
+
\82 bottles of beer on the wall, 82 bottles of beer.\n\
|
56
|
+
\Take one down and pass it around, 81 bottles of beer on the wall.\n\
|
57
|
+
\\n\
|
58
|
+
\81 bottles of beer on the wall, 81 bottles of beer.\n\
|
59
|
+
\Take one down and pass it around, 80 bottles of beer on the wall.\n\
|
60
|
+
\\n\
|
61
|
+
\80 bottles of beer on the wall, 80 bottles of beer.\n\
|
62
|
+
\Take one down and pass it around, 79 bottles of beer on the wall.\n\
|
63
|
+
\\n\
|
64
|
+
\79 bottles of beer on the wall, 79 bottles of beer.\n\
|
65
|
+
\Take one down and pass it around, 78 bottles of beer on the wall.\n\
|
66
|
+
\\n\
|
67
|
+
\78 bottles of beer on the wall, 78 bottles of beer.\n\
|
68
|
+
\Take one down and pass it around, 77 bottles of beer on the wall.\n\
|
69
|
+
\\n\
|
70
|
+
\77 bottles of beer on the wall, 77 bottles of beer.\n\
|
71
|
+
\Take one down and pass it around, 76 bottles of beer on the wall.\n\
|
72
|
+
\\n\
|
73
|
+
\76 bottles of beer on the wall, 76 bottles of beer.\n\
|
74
|
+
\Take one down and pass it around, 75 bottles of beer on the wall.\n\
|
75
|
+
\\n\
|
76
|
+
\75 bottles of beer on the wall, 75 bottles of beer.\n\
|
77
|
+
\Take one down and pass it around, 74 bottles of beer on the wall.\n\
|
78
|
+
\\n\
|
79
|
+
\74 bottles of beer on the wall, 74 bottles of beer.\n\
|
80
|
+
\Take one down and pass it around, 73 bottles of beer on the wall.\n\
|
81
|
+
\\n\
|
82
|
+
\73 bottles of beer on the wall, 73 bottles of beer.\n\
|
83
|
+
\Take one down and pass it around, 72 bottles of beer on the wall.\n\
|
84
|
+
\\n\
|
85
|
+
\72 bottles of beer on the wall, 72 bottles of beer.\n\
|
86
|
+
\Take one down and pass it around, 71 bottles of beer on the wall.\n\
|
87
|
+
\\n\
|
88
|
+
\71 bottles of beer on the wall, 71 bottles of beer.\n\
|
89
|
+
\Take one down and pass it around, 70 bottles of beer on the wall.\n\
|
90
|
+
\\n\
|
91
|
+
\70 bottles of beer on the wall, 70 bottles of beer.\n\
|
92
|
+
\Take one down and pass it around, 69 bottles of beer on the wall.\n\
|
93
|
+
\\n\
|
94
|
+
\69 bottles of beer on the wall, 69 bottles of beer.\n\
|
95
|
+
\Take one down and pass it around, 68 bottles of beer on the wall.\n\
|
96
|
+
\\n\
|
97
|
+
\68 bottles of beer on the wall, 68 bottles of beer.\n\
|
98
|
+
\Take one down and pass it around, 67 bottles of beer on the wall.\n\
|
99
|
+
\\n\
|
100
|
+
\67 bottles of beer on the wall, 67 bottles of beer.\n\
|
101
|
+
\Take one down and pass it around, 66 bottles of beer on the wall.\n\
|
102
|
+
\\n\
|
103
|
+
\66 bottles of beer on the wall, 66 bottles of beer.\n\
|
104
|
+
\Take one down and pass it around, 65 bottles of beer on the wall.\n\
|
105
|
+
\\n\
|
106
|
+
\65 bottles of beer on the wall, 65 bottles of beer.\n\
|
107
|
+
\Take one down and pass it around, 64 bottles of beer on the wall.\n\
|
108
|
+
\\n\
|
109
|
+
\64 bottles of beer on the wall, 64 bottles of beer.\n\
|
110
|
+
\Take one down and pass it around, 63 bottles of beer on the wall.\n\
|
111
|
+
\\n\
|
112
|
+
\63 bottles of beer on the wall, 63 bottles of beer.\n\
|
113
|
+
\Take one down and pass it around, 62 bottles of beer on the wall.\n\
|
114
|
+
\\n\
|
115
|
+
\62 bottles of beer on the wall, 62 bottles of beer.\n\
|
116
|
+
\Take one down and pass it around, 61 bottles of beer on the wall.\n\
|
117
|
+
\\n\
|
118
|
+
\61 bottles of beer on the wall, 61 bottles of beer.\n\
|
119
|
+
\Take one down and pass it around, 60 bottles of beer on the wall.\n\
|
120
|
+
\\n\
|
121
|
+
\60 bottles of beer on the wall, 60 bottles of beer.\n\
|
122
|
+
\Take one down and pass it around, 59 bottles of beer on the wall.\n\
|
123
|
+
\\n\
|
124
|
+
\59 bottles of beer on the wall, 59 bottles of beer.\n\
|
125
|
+
\Take one down and pass it around, 58 bottles of beer on the wall.\n\
|
126
|
+
\\n\
|
127
|
+
\58 bottles of beer on the wall, 58 bottles of beer.\n\
|
128
|
+
\Take one down and pass it around, 57 bottles of beer on the wall.\n\
|
129
|
+
\\n\
|
130
|
+
\57 bottles of beer on the wall, 57 bottles of beer.\n\
|
131
|
+
\Take one down and pass it around, 56 bottles of beer on the wall.\n\
|
132
|
+
\\n\
|
133
|
+
\56 bottles of beer on the wall, 56 bottles of beer.\n\
|
134
|
+
\Take one down and pass it around, 55 bottles of beer on the wall.\n\
|
135
|
+
\\n\
|
136
|
+
\55 bottles of beer on the wall, 55 bottles of beer.\n\
|
137
|
+
\Take one down and pass it around, 54 bottles of beer on the wall.\n\
|
138
|
+
\\n\
|
139
|
+
\54 bottles of beer on the wall, 54 bottles of beer.\n\
|
140
|
+
\Take one down and pass it around, 53 bottles of beer on the wall.\n\
|
141
|
+
\\n\
|
142
|
+
\53 bottles of beer on the wall, 53 bottles of beer.\n\
|
143
|
+
\Take one down and pass it around, 52 bottles of beer on the wall.\n\
|
144
|
+
\\n\
|
145
|
+
\52 bottles of beer on the wall, 52 bottles of beer.\n\
|
146
|
+
\Take one down and pass it around, 51 bottles of beer on the wall.\n\
|
147
|
+
\\n\
|
148
|
+
\51 bottles of beer on the wall, 51 bottles of beer.\n\
|
149
|
+
\Take one down and pass it around, 50 bottles of beer on the wall.\n\
|
150
|
+
\\n\
|
151
|
+
\50 bottles of beer on the wall, 50 bottles of beer.\n\
|
152
|
+
\Take one down and pass it around, 49 bottles of beer on the wall.\n\
|
153
|
+
\\n\
|
154
|
+
\49 bottles of beer on the wall, 49 bottles of beer.\n\
|
155
|
+
\Take one down and pass it around, 48 bottles of beer on the wall.\n\
|
156
|
+
\\n\
|
157
|
+
\48 bottles of beer on the wall, 48 bottles of beer.\n\
|
158
|
+
\Take one down and pass it around, 47 bottles of beer on the wall.\n\
|
159
|
+
\\n\
|
160
|
+
\47 bottles of beer on the wall, 47 bottles of beer.\n\
|
161
|
+
\Take one down and pass it around, 46 bottles of beer on the wall.\n\
|
162
|
+
\\n\
|
163
|
+
\46 bottles of beer on the wall, 46 bottles of beer.\n\
|
164
|
+
\Take one down and pass it around, 45 bottles of beer on the wall.\n\
|
165
|
+
\\n\
|
166
|
+
\45 bottles of beer on the wall, 45 bottles of beer.\n\
|
167
|
+
\Take one down and pass it around, 44 bottles of beer on the wall.\n\
|
168
|
+
\\n\
|
169
|
+
\44 bottles of beer on the wall, 44 bottles of beer.\n\
|
170
|
+
\Take one down and pass it around, 43 bottles of beer on the wall.\n\
|
171
|
+
\\n\
|
172
|
+
\43 bottles of beer on the wall, 43 bottles of beer.\n\
|
173
|
+
\Take one down and pass it around, 42 bottles of beer on the wall.\n\
|
174
|
+
\\n\
|
175
|
+
\42 bottles of beer on the wall, 42 bottles of beer.\n\
|
176
|
+
\Take one down and pass it around, 41 bottles of beer on the wall.\n\
|
177
|
+
\\n\
|
178
|
+
\41 bottles of beer on the wall, 41 bottles of beer.\n\
|
179
|
+
\Take one down and pass it around, 40 bottles of beer on the wall.\n\
|
180
|
+
\\n\
|
181
|
+
\40 bottles of beer on the wall, 40 bottles of beer.\n\
|
182
|
+
\Take one down and pass it around, 39 bottles of beer on the wall.\n\
|
183
|
+
\\n\
|
184
|
+
\39 bottles of beer on the wall, 39 bottles of beer.\n\
|
185
|
+
\Take one down and pass it around, 38 bottles of beer on the wall.\n\
|
186
|
+
\\n\
|
187
|
+
\38 bottles of beer on the wall, 38 bottles of beer.\n\
|
188
|
+
\Take one down and pass it around, 37 bottles of beer on the wall.\n\
|
189
|
+
\\n\
|
190
|
+
\37 bottles of beer on the wall, 37 bottles of beer.\n\
|
191
|
+
\Take one down and pass it around, 36 bottles of beer on the wall.\n\
|
192
|
+
\\n\
|
193
|
+
\36 bottles of beer on the wall, 36 bottles of beer.\n\
|
194
|
+
\Take one down and pass it around, 35 bottles of beer on the wall.\n\
|
195
|
+
\\n\
|
196
|
+
\35 bottles of beer on the wall, 35 bottles of beer.\n\
|
197
|
+
\Take one down and pass it around, 34 bottles of beer on the wall.\n\
|
198
|
+
\\n\
|
199
|
+
\34 bottles of beer on the wall, 34 bottles of beer.\n\
|
200
|
+
\Take one down and pass it around, 33 bottles of beer on the wall.\n\
|
201
|
+
\\n\
|
202
|
+
\33 bottles of beer on the wall, 33 bottles of beer.\n\
|
203
|
+
\Take one down and pass it around, 32 bottles of beer on the wall.\n\
|
204
|
+
\\n\
|
205
|
+
\32 bottles of beer on the wall, 32 bottles of beer.\n\
|
206
|
+
\Take one down and pass it around, 31 bottles of beer on the wall.\n\
|
207
|
+
\\n\
|
208
|
+
\31 bottles of beer on the wall, 31 bottles of beer.\n\
|
209
|
+
\Take one down and pass it around, 30 bottles of beer on the wall.\n\
|
210
|
+
\\n\
|
211
|
+
\30 bottles of beer on the wall, 30 bottles of beer.\n\
|
212
|
+
\Take one down and pass it around, 29 bottles of beer on the wall.\n\
|
213
|
+
\\n\
|
214
|
+
\29 bottles of beer on the wall, 29 bottles of beer.\n\
|
215
|
+
\Take one down and pass it around, 28 bottles of beer on the wall.\n\
|
216
|
+
\\n\
|
217
|
+
\28 bottles of beer on the wall, 28 bottles of beer.\n\
|
218
|
+
\Take one down and pass it around, 27 bottles of beer on the wall.\n\
|
219
|
+
\\n\
|
220
|
+
\27 bottles of beer on the wall, 27 bottles of beer.\n\
|
221
|
+
\Take one down and pass it around, 26 bottles of beer on the wall.\n\
|
222
|
+
\\n\
|
223
|
+
\26 bottles of beer on the wall, 26 bottles of beer.\n\
|
224
|
+
\Take one down and pass it around, 25 bottles of beer on the wall.\n\
|
225
|
+
\\n\
|
226
|
+
\25 bottles of beer on the wall, 25 bottles of beer.\n\
|
227
|
+
\Take one down and pass it around, 24 bottles of beer on the wall.\n\
|
228
|
+
\\n\
|
229
|
+
\24 bottles of beer on the wall, 24 bottles of beer.\n\
|
230
|
+
\Take one down and pass it around, 23 bottles of beer on the wall.\n\
|
231
|
+
\\n\
|
232
|
+
\23 bottles of beer on the wall, 23 bottles of beer.\n\
|
233
|
+
\Take one down and pass it around, 22 bottles of beer on the wall.\n\
|
234
|
+
\\n\
|
235
|
+
\22 bottles of beer on the wall, 22 bottles of beer.\n\
|
236
|
+
\Take one down and pass it around, 21 bottles of beer on the wall.\n\
|
237
|
+
\\n\
|
238
|
+
\21 bottles of beer on the wall, 21 bottles of beer.\n\
|
239
|
+
\Take one down and pass it around, 20 bottles of beer on the wall.\n\
|
240
|
+
\\n\
|
241
|
+
\20 bottles of beer on the wall, 20 bottles of beer.\n\
|
242
|
+
\Take one down and pass it around, 19 bottles of beer on the wall.\n\
|
243
|
+
\\n\
|
244
|
+
\19 bottles of beer on the wall, 19 bottles of beer.\n\
|
245
|
+
\Take one down and pass it around, 18 bottles of beer on the wall.\n\
|
246
|
+
\\n\
|
247
|
+
\18 bottles of beer on the wall, 18 bottles of beer.\n\
|
248
|
+
\Take one down and pass it around, 17 bottles of beer on the wall.\n\
|
249
|
+
\\n\
|
250
|
+
\17 bottles of beer on the wall, 17 bottles of beer.\n\
|
251
|
+
\Take one down and pass it around, 16 bottles of beer on the wall.\n\
|
252
|
+
\\n\
|
253
|
+
\16 bottles of beer on the wall, 16 bottles of beer.\n\
|
254
|
+
\Take one down and pass it around, 15 bottles of beer on the wall.\n\
|
255
|
+
\\n\
|
256
|
+
\15 bottles of beer on the wall, 15 bottles of beer.\n\
|
257
|
+
\Take one down and pass it around, 14 bottles of beer on the wall.\n\
|
258
|
+
\\n\
|
259
|
+
\14 bottles of beer on the wall, 14 bottles of beer.\n\
|
260
|
+
\Take one down and pass it around, 13 bottles of beer on the wall.\n\
|
261
|
+
\\n\
|
262
|
+
\13 bottles of beer on the wall, 13 bottles of beer.\n\
|
263
|
+
\Take one down and pass it around, 12 bottles of beer on the wall.\n\
|
264
|
+
\\n\
|
265
|
+
\12 bottles of beer on the wall, 12 bottles of beer.\n\
|
266
|
+
\Take one down and pass it around, 11 bottles of beer on the wall.\n\
|
267
|
+
\\n\
|
268
|
+
\11 bottles of beer on the wall, 11 bottles of beer.\n\
|
269
|
+
\Take one down and pass it around, 10 bottles of beer on the wall.\n\
|
270
|
+
\\n\
|
271
|
+
\10 bottles of beer on the wall, 10 bottles of beer.\n\
|
272
|
+
\Take one down and pass it around, 9 bottles of beer on the wall.\n\
|
273
|
+
\\n\
|
274
|
+
\9 bottles of beer on the wall, 9 bottles of beer.\n\
|
275
|
+
\Take one down and pass it around, 8 bottles of beer on the wall.\n\
|
276
|
+
\\n\
|
277
|
+
\8 bottles of beer on the wall, 8 bottles of beer.\n\
|
278
|
+
\Take one down and pass it around, 7 bottles of beer on the wall.\n\
|
279
|
+
\\n\
|
280
|
+
\7 bottles of beer on the wall, 7 bottles of beer.\n\
|
281
|
+
\Take one down and pass it around, 6 bottles of beer on the wall.\n\
|
282
|
+
\\n\
|
283
|
+
\6 bottles of beer on the wall, 6 bottles of beer.\n\
|
284
|
+
\Take one down and pass it around, 5 bottles of beer on the wall.\n\
|
285
|
+
\\n\
|
286
|
+
\5 bottles of beer on the wall, 5 bottles of beer.\n\
|
287
|
+
\Take one down and pass it around, 4 bottles of beer on the wall.\n\
|
288
|
+
\\n\
|
289
|
+
\4 bottles of beer on the wall, 4 bottles of beer.\n\
|
290
|
+
\Take one down and pass it around, 3 bottles of beer on the wall.\n\
|
291
|
+
\\n\
|
292
|
+
\3 bottles of beer on the wall, 3 bottles of beer.\n\
|
293
|
+
\Take one down and pass it around, 2 bottles of beer on the wall.\n\
|
294
|
+
\\n\
|
295
|
+
\2 bottles of beer on the wall, 2 bottles of beer.\n\
|
296
|
+
\Take one down and pass it around, 1 bottle of beer on the wall.\n\
|
297
|
+
\\n\
|
298
|
+
\1 bottle of beer on the wall, 1 bottle of beer.\n\
|
299
|
+
\Take it down and pass it around, no more bottles of beer on the wall.\n\
|
300
|
+
\\n\
|
301
|
+
\No more bottles of beer on the wall, no more bottles of beer.\n\
|
302
|
+
\Go to the store and buy some more, 99 bottles of beer on the wall.\n"
|
4
303
|
|
5
|
-
sing = undefined
|
@@ -1,5 +1,7 @@
|
|
1
|
-
module Beer (
|
1
|
+
module Beer (song) where
|
2
|
+
|
2
3
|
import Data.Char (toUpper)
|
4
|
+
import Data.List (intercalate)
|
3
5
|
|
4
6
|
capitalize :: String -> String
|
5
7
|
capitalize (h : t) = toUpper h : t
|
@@ -30,5 +32,5 @@ verse n = unlines
|
|
30
32
|
[ capitalize (stanza n) ++ " on the wall, " ++ stanza n ++ "."
|
31
33
|
, action n ++ ", " ++ stanza (pred n) ++ " on the wall." ]
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
+
song :: String
|
36
|
+
song = intercalate "\n" $ map verse [99, 98 .. 0]
|