Comments (14)
Uh, I don't remember ever submitting an exercism. 😄
from elixir.
Is that not you at the bottom of the readme?? http://exercism.io/exercises/elixir/accumulate/readme
from elixir.
That's me. Wild. I wonder what I said???
from elixir.
I believe you misread the actual code from the test. each char is being mapped with the function given, which returns a list with the char and [1,2,3]
as strings. the accumulate function does nothing special if the list passed in has a list as an element
I do agree that this test is confusingly named though
from elixir.
So I understood the test name to mean that the map function is applied recursively if a list element is encountered while iterating.
Thats why I put a recursive call in my implementation:
http://exercism.io/submissions/b907c6a12d6e4b0fae4bb664b3b8adbf#L22
Which I found out that the test suite passes without that line since the passed in anonymous function performs the second level "map".
I'm not sure what its trying to test if it doesn't require recursive mapping.
from elixir.
so yes, I think the test name is confusing and should be changed here
from elixir.
Yes, this looks confusing. Would someone mind submitting a PR with a better test description?
from elixir.
Is there a way you can reach this last test and have it fail? I don't see what it drives out, and the test itself is adding non-essential complexity (passing in a function that closes over a list), that has nothing to do with the function tested.
In a code base of my own, I'd remove it. If we change the name, I'd suggest "accumulate lists"
. Still pretty ambiguous, but perhaps less likely to lead someone to implement a deep map.
from elixir.
@martinsvalin I was suggesting, as you are, that we change the test (leaving the name) to have the user implement a deeply recursive map function. However useless it might be in real life, the exercise would be a good addition.
from elixir.
That's me. Wild. I wonder what I said???
@JEG2 I think this was during the Rogues retreat, and we were casually chatting about mentoring people, and you mentioned that you had gotten some of your mentees to reimplement enumerable methods.
from elixir.
Ah, could be!
from elixir.
I would suggest using accumulate
itself instead of for
and call it "nested accumulate"
:
test "nested accumulate" do
chars = ~w(a b c)
nums = ~w(1 2 3)
fun = fn(c) -> Accumulate.accumulate(nums, &(c <> &1)) end
expected = [["a1", "a2", "a3"], ["b1", "b2", "b3"], ["c1", "c2", "c3"]]
assert Accumulate.accumulate(chars, fun) == expected
end
from elixir.
I'm scratching my head on this. It looks to me like the original thought was to drive out deep mapping with something like:
test "accumulate recursively" do
values = [[1,2,3], [4, 5, 6]]
fun = fn(num) -> num * 2 end
expected = [[2, 4, 6], [8, 10, 12]]
assert Accumulate.accumulate(values, fun) == expected
end
@tejasbubane the change in your PR illustrates that Accumulate.accumulate/2
can take a function that allows it to compute the permutations of two lists. However, I don't see it driving out any additional behavior. This test, as @martinsvalin points out, has the non-essential complexity of closing over num
in the passed function.
My recommendation is that we either take this test out or make it drive out additional behavior.
from elixir.
@parkerl Agreed. It does not drive any additional behaviour. My idea was to give a better description to the test (nested
instead of recursive
) and since we already have accumulate
use that itself instead of for
. I am perfectly fine with removing the test entirely since it does not test anything new which the rest of the tests don't.
from elixir.
Related Issues (20)
- Top Secret could use another test HOT 2
- [Dancing Dots] "defines a __using__ macro" test is flakey in certain scenarios HOT 2
- [log-level] Misused trailing question marks HOT 1
- Set up a dead link checker
- Update all Elixir Exercism repos to use Elixir 1.15 and OTP 26 HOT 8
- Adjust all concepts to use charlist sigils
- test_exercises.sh print fails when test output includes `%`
- Lasagna exercise HOT 2
- Why does this repository have two identical github workflows? HOT 6
- Phone Number exercise: difference between tests in exercise folder vs online Test runner HOT 2
- Implement new practice exercise: bottle-song
- Too forgiving test in exercises/concept/german-sysadmin HOT 1
- Mistakes in `bottle-song` example solution typespecs HOT 3
- [RPG Character Sheet] Misleading the 5th question HOT 4
- Building a training set of tags for elixir HOT 22
- Run on Elixir 1.16
- Leap approaches for 48in24
- 48in24 Approaches for Raindrops HOT 2
- Darts exercise hint for sqrt workaround doesn't seem to work HOT 7
- Typo In Take-A-Number Deluxe Step 6 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elixir.