This issue describes how to implement the basic-strings concept exercise for the Elixir track.
Please please please read the docs before starting. Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time. So, before diving into the implementation, please read up on the following documents:
Please also watch the following video:
The goal of this exercise is to teach the student how strings are implemented and used in Elixir.
basic-stringsstring-interpolationheredocstuplesbasic-pattern-matchingstring-literalslooking for help in a few ways, and I am here to help you through getting this exercise off the ground:
Thanks for considering!
I have a silly idea. Remember how in school kids would manifest their love by drawing or scratching into a desk their initials and hearts?
We could ask the students to take two names and return a big ASCII heart with the initials:
iex> Heart.pair("Jake Smith", "Judy Adams")
"""
* * * * * *
* * * *
* * * *
* * *
* *
* J. S. + J. A. *
* *
* *
* *
* *
* *
* *
* *
*
"""
Getting the initials of a single name could be a separate function, later to be reused.
It's a bit unclear to me how to force students to learn concatenation when it can be replaced by interpolation to achieve the same results (e.g. x <> " - " <> y versus "#{x} - #{y}). Same with heredocs which can be replaced by concatenation.
I am also confused about why this issue already specifies that this concept exercise requires knowing the tuple and the basic-pattern-matching concepts first. I thought this can only be specified after we have an idea for the exercise. Or are we forced to come up with an idea that uses tuples and pattern-matching?
I really like this idea, and think it might work really well if we can break it up into a few functions that culminate in the final product.
It highlights some great things about strings without getting into singy songy exercises.
As far as the tuples/pattern matching as prereqs, they can change if we can solve this without them, for sure. I have deferred working with strings until having a bit of a plan for pattern matching because so many string functions return tuple pairs or lists and pattern matched on that result is very common, eg:
String.split_at("sweetelixir", 5)
# {"sweet", "elixir"}
As far as enforcing the exact convention, there is no way for us to do that directly with the exercise/test case. so if a student chooses a <> " " <> b over "#{a} #{b}" that'll pass the test case tests.
But this is where it might be useful for an analyzer module to be developed in order to develop static code analysis test cases to catch these patterns -- I have been working on an analyzer runner/DSL to do this at exercism/elixir-analyzer
Thinking about this, there could be a few steps which get us to this whihc then could guide the student through a few string exercises:
J. S. + J. A. ****** ******
** ** ** **
** ** ** **
** * **
** **
** J. S. + J. A. **
** **
** **
** **
** **
** **
** **
***
*
@angelikatyborska - The next steps (if you want to keep going with this) are:
elixir-concept-basic-strings to make use of CI tooling. To do that:@neenjaw Yes, please, I would like to keep going :). I'll start working locally on this exercise until I have permissions to push to this repo. Let's sync on Slack about making that happen.
@neenjaw I opened a draft PR and left a bunch of comments so that we could talk about specific points: https://github.com/exercism/v3/pull/1468/files
We need to connect with @ErikSchierboom to get you added as a code owner in elixir, and that's done by adding you to the maintainers.json in the exercism/elixir repo, which I am happy to do as long is okay with them.
That is totally okay! Great to have you working on the v3 track @angelikatyborska!
closing secondary to #1468 merged