trackler 2.2.1.8 → 2.2.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +0 -6
  3. data/lib/trackler/version.rb +1 -1
  4. data/problem-specifications/exercises/palindrome-products/description.md +5 -5
  5. data/tracks/clojure/config/maintainers.json +45 -0
  6. data/tracks/coq/config.json +1 -1
  7. data/tracks/csharp/config.json +257 -253
  8. data/tracks/delphi/config/maintainers.json +1 -1
  9. data/tracks/erlang/exercises/accumulate/include/exercism.hrl +4 -4
  10. data/tracks/erlang/exercises/accumulate/src/accumulate.erl +8 -0
  11. data/tracks/erlang/exercises/all-your-base/include/exercism.hrl +4 -4
  12. data/tracks/erlang/exercises/all-your-base/src/all_your_base.erl +8 -0
  13. data/tracks/erlang/exercises/allergies/include/exercism.hrl +4 -4
  14. data/tracks/erlang/exercises/allergies/src/allergies.erl +8 -0
  15. data/tracks/erlang/exercises/anagram/include/exercism.hrl +4 -4
  16. data/tracks/erlang/exercises/anagram/src/anagram.erl +8 -0
  17. data/tracks/erlang/exercises/atbash-cipher/include/exercism.hrl +4 -4
  18. data/tracks/erlang/exercises/atbash-cipher/src/atbash_cipher.erl +11 -0
  19. data/tracks/erlang/exercises/bank-account/include/exercism.hrl +4 -4
  20. data/tracks/erlang/exercises/bank-account/src/bank_account.erl +23 -0
  21. data/tracks/erlang/exercises/beer-song/include/exercism.hrl +4 -4
  22. data/tracks/erlang/exercises/beer-song/src/beer_song.erl +14 -0
  23. data/tracks/erlang/exercises/bob/include/exercism.hrl +4 -4
  24. data/tracks/erlang/exercises/bob/src/bob.erl +8 -0
  25. data/tracks/erlang/exercises/circular-buffer/include/exercism.hrl +4 -4
  26. data/tracks/erlang/exercises/circular-buffer/src/circular_buffer.erl +20 -0
  27. data/tracks/erlang/exercises/clock/include/exercism.hrl +4 -4
  28. data/tracks/erlang/exercises/clock/src/clock.erl +17 -0
  29. data/tracks/erlang/exercises/collatz-conjecture/include/exercism.hrl +4 -4
  30. data/tracks/erlang/exercises/collatz-conjecture/src/collatz_conjecture.erl +9 -0
  31. data/tracks/erlang/exercises/difference-of-squares/include/exercism.hrl +4 -4
  32. data/tracks/erlang/exercises/difference-of-squares/src/difference_of_squares.erl +14 -0
  33. data/tracks/erlang/exercises/etl/include/exercism.hrl +4 -4
  34. data/tracks/erlang/exercises/etl/src/etl.erl +8 -0
  35. data/tracks/erlang/exercises/gigasecond/include/exercism.hrl +4 -4
  36. data/tracks/erlang/exercises/gigasecond/src/gigasecond.erl +8 -0
  37. data/tracks/erlang/exercises/grade-school/include/exercism.hrl +4 -4
  38. data/tracks/erlang/exercises/grade-school/src/grade_school.erl +17 -0
  39. data/tracks/erlang/exercises/grains/include/exercism.hrl +4 -4
  40. data/tracks/erlang/exercises/grains/src/grains.erl +11 -0
  41. data/tracks/erlang/exercises/hamming/include/exercism.hrl +4 -4
  42. data/tracks/erlang/exercises/hamming/src/hamming.erl +8 -0
  43. data/tracks/erlang/exercises/hello-world/include/exercism.hrl +4 -4
  44. data/tracks/erlang/exercises/hello-world/src/hello_world.erl +8 -0
  45. data/tracks/erlang/exercises/largest-series-product/include/exercism.hrl +4 -4
  46. data/tracks/erlang/exercises/largest-series-product/src/largest_series_product.erl +8 -0
  47. data/tracks/erlang/exercises/leap/include/exercism.hrl +4 -4
  48. data/tracks/erlang/exercises/leap/src/leap.erl +8 -0
  49. data/tracks/erlang/exercises/luhn/include/exercism.hrl +4 -4
  50. data/tracks/erlang/exercises/luhn/src/luhn.erl +11 -0
  51. data/tracks/erlang/exercises/meetup/include/exercism.hrl +4 -4
  52. data/tracks/erlang/exercises/meetup/src/meetup.erl +8 -0
  53. data/tracks/erlang/exercises/nucleotide-count/include/exercism.hrl +4 -4
  54. data/tracks/erlang/exercises/nucleotide-count/src/nucleotide_count.erl +11 -0
  55. data/tracks/erlang/exercises/parallel-letter-frequency/include/exercism.hrl +4 -4
  56. data/tracks/erlang/exercises/parallel-letter-frequency/src/parallel_letter_frequency.erl +8 -0
  57. data/tracks/erlang/exercises/phone-number/include/exercism.hrl +4 -4
  58. data/tracks/erlang/exercises/phone-number/src/phone_number.erl +14 -0
  59. data/tracks/erlang/exercises/rna-transcription/include/exercism.hrl +4 -4
  60. data/tracks/erlang/exercises/rna-transcription/src/rna_transcription.erl +8 -0
  61. data/tracks/erlang/exercises/robot-simulator/include/exercism.hrl +4 -4
  62. data/tracks/erlang/exercises/robot-simulator/src/robot_simulator.erl +29 -0
  63. data/tracks/erlang/exercises/roman-numerals/include/exercism.hrl +4 -4
  64. data/tracks/erlang/exercises/roman-numerals/src/roman_numerals.erl +8 -0
  65. data/tracks/erlang/exercises/rotational-cipher/include/exercism.hrl +4 -4
  66. data/tracks/erlang/exercises/rotational-cipher/src/rotational_cipher.erl +11 -0
  67. data/tracks/erlang/exercises/scrabble-score/include/exercism.hrl +4 -4
  68. data/tracks/erlang/exercises/scrabble-score/src/scrabble_score.erl +8 -0
  69. data/tracks/erlang/exercises/series/include/exercism.hrl +4 -4
  70. data/tracks/erlang/exercises/series/src/series.erl +8 -0
  71. data/tracks/erlang/exercises/space-age/include/exercism.hrl +4 -4
  72. data/tracks/erlang/exercises/space-age/src/space_age.erl +8 -0
  73. data/tracks/erlang/exercises/spiral-matrix/include/exercism.hrl +4 -4
  74. data/tracks/erlang/exercises/spiral-matrix/src/spiral_matrix.erl +8 -0
  75. data/tracks/erlang/exercises/strain/include/exercism.hrl +4 -4
  76. data/tracks/erlang/exercises/strain/src/strain.erl +11 -0
  77. data/tracks/erlang/exercises/sum-of-multiples/include/exercism.hrl +4 -4
  78. data/tracks/erlang/exercises/sum-of-multiples/src/sum_of_multiples.erl +8 -0
  79. data/tracks/erlang/exercises/triangle/include/exercism.hrl +4 -4
  80. data/tracks/erlang/exercises/triangle/src/triangle.erl +8 -0
  81. data/tracks/erlang/exercises/word-count/include/exercism.hrl +4 -4
  82. data/tracks/erlang/exercises/word-count/src/word_count.erl +8 -0
  83. data/tracks/erlang/exercises/zipper/include/exercism.hrl +4 -4
  84. data/tracks/erlang/exercises/zipper/src/example.erl +2 -6
  85. data/tracks/erlang/exercises/zipper/src/zipper.erl +37 -0
  86. data/tracks/erlang/exercises/zipper/test/zipper_tests.erl +1 -1
  87. data/tracks/factor/config/maintainers.json +15 -0
  88. data/tracks/fsharp/config.json +249 -248
  89. data/tracks/go/config.json +93 -34
  90. data/tracks/julia/README.md +3 -3
  91. data/tracks/julia/config/maintainers.json +15 -0
  92. data/tracks/rust/config.json +10 -0
  93. data/tracks/rust/exercises/accumulate/.meta/hints.md +10 -0
  94. data/tracks/rust/exercises/accumulate/Cargo.lock +4 -0
  95. data/tracks/rust/exercises/accumulate/Cargo.toml +6 -0
  96. data/tracks/rust/exercises/accumulate/README.md +79 -0
  97. data/tracks/rust/exercises/accumulate/example.rs +15 -0
  98. data/tracks/{chapel/docs/ABOUT.md → rust/exercises/accumulate/src/lib.rs} +0 -0
  99. data/tracks/rust/exercises/accumulate/tests/accumulate.rs +94 -0
  100. metadata +50 -30
  101. data/tracks/chapel/.git +0 -1
  102. data/tracks/chapel/.gitignore +0 -4
  103. data/tracks/chapel/.travis.yml +0 -5
  104. data/tracks/chapel/LICENSE +0 -21
  105. data/tracks/chapel/README.md +0 -11
  106. data/tracks/chapel/bin/fetch-configlet +0 -32
  107. data/tracks/chapel/config/exercise_readme.go.tmpl +0 -16
  108. data/tracks/chapel/config/maintainers.json +0 -5
  109. data/tracks/chapel/config.json +0 -11
  110. data/tracks/chapel/docs/EXERCISE_README_INSERT.md +0 -0
  111. data/tracks/chapel/docs/INSTALLATION.md +0 -0
  112. data/tracks/chapel/docs/LEARNING.md +0 -0
  113. data/tracks/chapel/docs/RESOURCES.md +0 -0
  114. data/tracks/chapel/docs/TESTS.md +0 -0
  115. data/tracks/chapel/exercises/.keep +0 -0
  116. data/tracks/chapel/img/.keep +0 -0
  117. data/tracks/nasm/.git +0 -1
  118. data/tracks/nasm/.gitignore +0 -2
  119. data/tracks/nasm/.travis.yml +0 -6
  120. data/tracks/nasm/LICENSE +0 -21
  121. data/tracks/nasm/README.md +0 -11
  122. data/tracks/nasm/bin/fetch-configlet +0 -32
  123. data/tracks/nasm/config/exercise_readme.go.tmpl +0 -16
  124. data/tracks/nasm/config.json +0 -11
  125. data/tracks/nasm/docs/EXERCISE_README_INSERT.md +0 -0
  126. data/tracks/nasm/exercises/.keep +0 -0
  127. data/tracks/nasm/img/icon.png +0 -0
@@ -700,9 +700,11 @@
700
700
  "slug": "nucleotide-count",
701
701
  "core": false,
702
702
  "unlocked_by": null,
703
- "difficulty": 1,
703
+ "difficulty": 2,
704
704
  "topics": [
705
-
705
+ "Strings",
706
+ "Parsing",
707
+ "Maps"
706
708
  ]
707
709
  },
708
710
  {
@@ -722,9 +724,13 @@
722
724
  "slug": "matrix",
723
725
  "core": false,
724
726
  "unlocked_by": null,
725
- "difficulty": 1,
727
+ "difficulty": 4,
726
728
  "topics": [
727
-
729
+ "Matrices",
730
+ "Type conversion",
731
+ "Arrays",
732
+ "Exception handling",
733
+ "Strings"
728
734
  ]
729
735
  },
730
736
  {
@@ -732,9 +738,12 @@
732
738
  "slug": "saddle-points",
733
739
  "core": false,
734
740
  "unlocked_by": null,
735
- "difficulty": 1,
741
+ "difficulty": 5,
736
742
  "topics": [
737
-
743
+ "Arrays",
744
+ "Integers",
745
+ "Matrices",
746
+ "Searching"
738
747
  ]
739
748
  },
740
749
  {
@@ -742,9 +751,12 @@
742
751
  "slug": "meetup",
743
752
  "core": false,
744
753
  "unlocked_by": null,
745
- "difficulty": 1,
754
+ "difficulty": 3,
746
755
  "topics": [
747
-
756
+ "Dates",
757
+ "Time",
758
+ "Transforming",
759
+ "Type conversion"
748
760
  ]
749
761
  },
750
762
  {
@@ -752,9 +764,12 @@
752
764
  "slug": "binary-search",
753
765
  "core": false,
754
766
  "unlocked_by": null,
755
- "difficulty": 1,
767
+ "difficulty": 5,
756
768
  "topics": [
757
-
769
+ "Algorithms",
770
+ "Arrays",
771
+ "Searching",
772
+ "Sorting"
758
773
  ]
759
774
  },
760
775
  {
@@ -762,9 +777,14 @@
762
777
  "slug": "binary-search-tree",
763
778
  "core": false,
764
779
  "unlocked_by": null,
765
- "difficulty": 1,
780
+ "difficulty": 5,
766
781
  "topics": [
767
-
782
+ "Algorithms",
783
+ "Recursion",
784
+ "Searching",
785
+ "Sorting",
786
+ "Structs",
787
+ "Trees"
768
788
  ]
769
789
  },
770
790
  {
@@ -772,9 +792,12 @@
772
792
  "slug": "tree-building",
773
793
  "core": false,
774
794
  "unlocked_by": null,
775
- "difficulty": 1,
795
+ "difficulty": 3,
776
796
  "topics": [
777
-
797
+ "Records",
798
+ "Refactoring",
799
+ "Sorting",
800
+ "Trees"
778
801
  ]
779
802
  },
780
803
  {
@@ -782,9 +805,13 @@
782
805
  "slug": "kindergarten-garden",
783
806
  "core": false,
784
807
  "unlocked_by": null,
785
- "difficulty": 1,
808
+ "difficulty": 3,
786
809
  "topics": [
787
-
810
+ "Parsing",
811
+ "Records",
812
+ "Searching",
813
+ "Strings",
814
+ "Structs"
788
815
  ]
789
816
  },
790
817
  {
@@ -792,9 +819,13 @@
792
819
  "slug": "simple-cipher",
793
820
  "core": false,
794
821
  "unlocked_by": null,
795
- "difficulty": 1,
822
+ "difficulty": 3,
796
823
  "topics": [
797
-
824
+ "Algorithms",
825
+ "Interfaces",
826
+ "Security",
827
+ "Strings",
828
+ "Transforming"
798
829
  ]
799
830
  },
800
831
  {
@@ -802,9 +833,11 @@
802
833
  "slug": "paasio",
803
834
  "core": false,
804
835
  "unlocked_by": null,
805
- "difficulty": 1,
836
+ "difficulty": 5,
806
837
  "topics": [
807
-
838
+ "Concurrency",
839
+ "Interfaces",
840
+ "Networking"
808
841
  ]
809
842
  },
810
843
  {
@@ -812,9 +845,13 @@
812
845
  "slug": "pov",
813
846
  "core": false,
814
847
  "unlocked_by": null,
815
- "difficulty": 1,
848
+ "difficulty": 7,
816
849
  "topics": [
817
-
850
+ "Graphs",
851
+ "Recursion",
852
+ "Structs",
853
+ "Transforming",
854
+ "Trees"
818
855
  ]
819
856
  },
820
857
  {
@@ -822,9 +859,13 @@
822
859
  "slug": "minesweeper",
823
860
  "core": false,
824
861
  "unlocked_by": null,
825
- "difficulty": 1,
862
+ "difficulty": 5,
826
863
  "topics": [
827
-
864
+ "Arrays",
865
+ "Control-flow (loops)",
866
+ "Matrices",
867
+ "Games",
868
+ "Transforming"
828
869
  ]
829
870
  },
830
871
  {
@@ -832,9 +873,13 @@
832
873
  "slug": "robot-simulator",
833
874
  "core": false,
834
875
  "unlocked_by": null,
835
- "difficulty": 1,
876
+ "difficulty": 6,
836
877
  "topics": [
837
-
878
+ "Concurrency",
879
+ "Control-flow (loops)",
880
+ "Sequences",
881
+ "Strings",
882
+ "Structs"
838
883
  ]
839
884
  },
840
885
  {
@@ -842,9 +887,15 @@
842
887
  "slug": "tournament",
843
888
  "core": false,
844
889
  "unlocked_by": null,
845
- "difficulty": 1,
890
+ "difficulty": 3,
846
891
  "topics": [
847
-
892
+ "Integers",
893
+ "Parsing",
894
+ "Records",
895
+ "Sorting",
896
+ "Strings",
897
+ "Text formatting",
898
+ "Transforming"
848
899
  ]
849
900
  },
850
901
  {
@@ -852,9 +903,11 @@
852
903
  "slug": "word-search",
853
904
  "core": false,
854
905
  "unlocked_by": null,
855
- "difficulty": 1,
906
+ "difficulty": 4,
856
907
  "topics": [
857
-
908
+ "Matrices",
909
+ "Searching",
910
+ "Strings"
858
911
  ]
859
912
  },
860
913
  {
@@ -862,9 +915,11 @@
862
915
  "slug": "all-your-base",
863
916
  "core": false,
864
917
  "unlocked_by": null,
865
- "difficulty": 1,
918
+ "difficulty": 3,
866
919
  "topics": [
867
-
920
+ "Integers",
921
+ "Mathematics",
922
+ "Transforming"
868
923
  ]
869
924
  },
870
925
  {
@@ -872,9 +927,13 @@
872
927
  "slug": "connect",
873
928
  "core": false,
874
929
  "unlocked_by": null,
875
- "difficulty": 1,
930
+ "difficulty": 9,
876
931
  "topics": [
877
-
932
+ "Arrays",
933
+ "Control-flow (loops)",
934
+ "Games",
935
+ "Graphs",
936
+ "Searching"
878
937
  ]
879
938
  },
880
939
  {
@@ -1,7 +1,7 @@
1
1
  # Exercism Julia Track
2
2
 
3
- [![Join the chat at https://gitter.im/exercism/xjulia](https://badges.gitter.im/exercism/xjulia.svg)](https://gitter.im/exercism/xjulia?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
- [![Build Status](https://travis-ci.org/exercism/xjulia.svg?branch=master)](https://travis-ci.org/exercism/xjulia)
3
+ [![Join the chat at https://gitter.im/exercism/julia](https://badges.gitter.im/exercism/julia.svg)](https://gitter.im/exercism/julia?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
+ [![Build Status](https://travis-ci.org/exercism/julia.svg?branch=master)](https://travis-ci.org/exercism/julia)
5
5
 
6
6
  Exercism exercises in Julia.
7
7
 
@@ -29,7 +29,7 @@ Exercises for the Julia track go in the `exercises` directory and should follow
29
29
 
30
30
  Replace `<slug>` with the exercise slug of the exercise you're working on.
31
31
 
32
- See [Issue #2](https://github.com/exercism/xjulia/issues/2) for discussion on the structure and style guidelines.
32
+ See [Issue #2](https://github.com/exercism/julia/issues/2) for discussion on the structure and style guidelines.
33
33
 
34
34
  ### Adding it to config
35
35
 
@@ -0,0 +1,15 @@
1
+ {
2
+ "maintainers": [
3
+ {
4
+ "github_username": "SaschaMann",
5
+ "show_on_website": false,
6
+ "alumnus": false,
7
+ "name": null,
8
+ "bio": null,
9
+ "link_text": null,
10
+ "link_url": null,
11
+ "avatar_url": null
12
+ }
13
+ ],
14
+ "docs_url": "https://github.com/exercism/docs/blob/master/maintaining-a-track/maintainer-configuration.md"
15
+ }
@@ -312,6 +312,16 @@
312
312
  "btree"
313
313
  ]
314
314
  },
315
+ {
316
+ "uuid": "ddc45979-8a92-4313-a4f8-878562d5a483",
317
+ "slug": "accumulate",
318
+ "core": false,
319
+ "unlocked_by": null,
320
+ "difficulty": 4,
321
+ "topics": [
322
+ "function pointer"
323
+ ]
324
+ },
315
325
  {
316
326
  "uuid": "26a9102f-26f6-4238-858e-ba20db66f1a9",
317
327
  "slug": "acronym",
@@ -0,0 +1,10 @@
1
+ ## Hints
2
+
3
+ We are dealing with two types of situations. One is a function pointer and
4
+ the other is a closure.
5
+
6
+ It may help to look at the [Fn trait](https://doc.rust-lang.org/std/ops/trait.Fn.html).
7
+
8
+ Help with passing a closure into a function may be found in
9
+ the ["closures as input parameters" section](https://rustbyexample.com/fn/closures/input_parameters.html) of
10
+ [Rust by Example](https://rustbyexample.com/).
@@ -0,0 +1,4 @@
1
+ [root]
2
+ name = "accumulate"
3
+ version = "0.0.0"
4
+
@@ -0,0 +1,6 @@
1
+ [package]
2
+ name = "accumulate"
3
+ version = "0.0.0"
4
+ authors = ["sacherjj <sacherjj@gmail.com>"]
5
+
6
+ [dependencies]
@@ -0,0 +1,79 @@
1
+ # Accumulate
2
+
3
+ Implement the `accumulate` operation, which, given a collection and an
4
+ operation to perform on each element of the collection, returns a new
5
+ collection containing the result of applying that operation to each element of
6
+ the input collection.
7
+
8
+ Given the collection of numbers:
9
+
10
+ - 1, 2, 3, 4, 5
11
+
12
+ And the operation:
13
+
14
+ - square a number (`x => x * x`)
15
+
16
+ Your code should be able to produce the collection of squares:
17
+
18
+ - 1, 4, 9, 16, 25
19
+
20
+ Check out the test suite to see the expected function signature.
21
+
22
+ ## Restrictions
23
+
24
+ Keep your hands off that collect/map/fmap/whatchamacallit functionality
25
+ provided by your standard library!
26
+ Solve this one yourself using other basic tools instead.
27
+
28
+ Lisp specific: it's perfectly fine to use `MAPCAR` or the equivalent,
29
+ as this is idiomatic Lisp, not a library function.
30
+
31
+ ## Hints
32
+
33
+ We are dealing with two types of situations. One is a function pointer and
34
+ the other is a closure.
35
+
36
+ It may help to look at the [Fn trait](https://doc.rust-lang.org/std/ops/trait.Fn.html).
37
+
38
+ Help with passing a closure into a function may be found in
39
+ the ["closures as input parameters" section](https://rustbyexample.com/fn/closures/input_parameters.html) of
40
+ [Rust by Example](https://rustbyexample.com/).
41
+
42
+
43
+ ## Rust Installation
44
+
45
+ Refer to the [exercism help page][help-page] for Rust installation and learning
46
+ resources.
47
+
48
+ ## Writing the Code
49
+
50
+ Execute the tests with:
51
+
52
+ ```bash
53
+ $ cargo test
54
+ ```
55
+
56
+ All but the first test have been ignored. After you get the first test to
57
+ pass, remove the ignore flag (`#[ignore]`) from the next test and get the tests
58
+ to pass again. The test file is located in the `tests` directory. You can
59
+ also remove the ignore flag from all the tests to get them to run all at once
60
+ if you wish.
61
+
62
+ Make sure to read the [Crates and Modules](https://doc.rust-lang.org/stable/book/crates-and-modules.html) chapter if you
63
+ haven't already, it will help you with organizing your files.
64
+
65
+ ## Feedback, Issues, Pull Requests
66
+
67
+ The [exercism/rust](https://github.com/exercism/rust) repository on GitHub is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the [rust track team](https://github.com/orgs/exercism/teams/rust) are happy to help!
68
+
69
+ If you want to know more about Exercism, take a look at the [contribution guide](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md).
70
+
71
+ [help-page]: http://exercism.io/languages/rust
72
+ [crates-and-modules]: http://doc.rust-lang.org/stable/book/crates-and-modules.html
73
+
74
+ ## Source
75
+
76
+ Conversation with James Edward Gray II [https://twitter.com/jeg2](https://twitter.com/jeg2)
77
+
78
+ ## Submitting Incomplete Solutions
79
+ It's possible to submit an incomplete solution so you can see how others have completed the exercise.
@@ -0,0 +1,15 @@
1
+ pub fn map_function(values: Vec<i32>, f: &Fn(i32) -> i32) -> Vec<i32> {
2
+ let mut out: Vec<i32> = vec![];
3
+ for val in values {
4
+ out.push(f(val))
5
+ }
6
+ out
7
+ }
8
+
9
+ pub fn map_closure<F>(values: Vec<i32>, f: F) -> Vec<i32> where F: Fn(i32) -> i32 {
10
+ let mut out: Vec<i32> = vec![];
11
+ for val in values {
12
+ out.push(f(val))
13
+ }
14
+ out
15
+ }
@@ -0,0 +1,94 @@
1
+ extern crate accumulate;
2
+
3
+ use accumulate::{map_function, map_closure};
4
+
5
+ fn square(x: i32) -> i32 {
6
+ x*x
7
+ }
8
+
9
+ fn abs_val(x: i32) -> i32 {
10
+ if x > 0 {
11
+ x
12
+ } else {
13
+ -x
14
+ }
15
+ }
16
+
17
+ #[test]
18
+ fn test_func_square_single() {
19
+ let input = vec![2];
20
+ let expected = vec![4];
21
+ assert_eq!(map_function(input, &square), expected);
22
+ }
23
+
24
+ #[test]
25
+ #[ignore]
26
+ fn test_func_square_short() {
27
+ let input = vec![2, 3, 4, 5];
28
+ let expected = vec![4, 9, 16, 25];
29
+ assert_eq!(map_function(input, &square), expected);
30
+ }
31
+
32
+ #[test]
33
+ #[ignore]
34
+ fn test_func_square_long_with_neg() {
35
+ let input = vec![2, -3, -2, 3, 4, 3, 4, 5, 100, 8, 16, 34];
36
+ let expected = vec![4, 9, 4, 9, 16, 9, 16, 25, 10000, 64, 256, 1156];
37
+ assert_eq!(map_function(input, &square), expected);
38
+ }
39
+
40
+ #[test]
41
+ #[ignore]
42
+ fn test_func_abs_value_with_neg() {
43
+ let input = vec![-3];
44
+ let expected = vec![3];
45
+ assert_eq!(map_function(input, &abs_val), expected);
46
+ }
47
+
48
+ #[test]
49
+ #[ignore]
50
+ fn test_func_abs_value_long() {
51
+ let input = vec![-3, 5, -10, 4, 100, -1234, 55443];
52
+ let expected = vec![3, 5, 10, 4, 100, 1234, 55443];
53
+ assert_eq!(map_function(input, &abs_val), expected);
54
+ }
55
+
56
+ #[test]
57
+ #[ignore]
58
+ fn test_closure_square_single() {
59
+ let input = vec![2];
60
+ let expected = vec![4];
61
+ assert_eq!(map_closure(input, |x| x*x), expected);
62
+ }
63
+
64
+ #[test]
65
+ #[ignore]
66
+ fn test_closure_square_short() {
67
+ let input = vec![2, 3, 4, 5];
68
+ let expected = vec![4, 9, 16, 25];
69
+ assert_eq!(map_closure(input, |x| x*x), expected);
70
+ }
71
+
72
+ #[test]
73
+ #[ignore]
74
+ fn test_closure_square_long_with_neg() {
75
+ let input = vec![2, -3, -2, 3, 4, 3, 4, 5, 100, 8, 16, 34];
76
+ let expected = vec![4, 9, 4, 9, 16, 9, 16, 25, 10000, 64, 256, 1156];
77
+ assert_eq!(map_closure(input, |x| x*x), expected);
78
+ }
79
+
80
+ #[test]
81
+ #[ignore]
82
+ fn test_closure_abs_value_with_neg() {
83
+ let input = vec![-3];
84
+ let expected = vec![3];
85
+ assert_eq!(map_closure(input, |x| if x > 0 {x} else {-x}), expected);
86
+ }
87
+
88
+ #[test]
89
+ #[ignore]
90
+ fn test_closure_abs_value_long() {
91
+ let input = vec![-3, 5, -10, 4, 100, -1234, 55443];
92
+ let expected = vec![3, 5, 10, 4, 100, 1234, 55443];
93
+ assert_eq!(map_closure(input, |x| if x > 0 {x} else {-x}), expected);
94
+ }