V3: [Elixir] new Concept Exercise: basic-strings

Created on 15 May 2020  路  8Comments  路  Source: exercism/v3

This issue describes how to implement the basic-strings concept exercise for the Elixir track.

Getting started

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:

馃敆 How to help

Goal

The goal of this exercise is to teach the student how strings are implemented and used in Elixir.

Learning objectives

  • Know how to concatenate strings
  • Know how to manipulate strings
  • Know how to perform string interpolation
  • Know how to create multi-line strings (heredocs)

    • Know about the features/benefits of heredocs

Out of scope

  • Strings as binaries for binary pattern matching

Concepts

  • basic-strings
  • string-interpolation
  • heredocs

Prerequisites

  • tuples
  • basic-pattern-matching
  • string-literals

Resources to refer to

Actionable items 馃敆

looking for help in a few ways, and I am here to help you through getting this exercise off the ground:

  • [ ] Need help coming up with a basic premise for the exercise (What and why are we manipulating strings for?)

    • Don't want to write it completely? Post your basic idea and I'm happy to write it with/for you

  • [ ] Writing the exemplar solution (How can we fulfill the premise of the exercise with following the scope of requirements)

    • If we can't fulfill the premise with the current scope, then we need to adjust:

    • the premise

    • the code

    • the requirements

  • [ ] Writing the test cases (if TDD is your thing!)
  • [ ] Writing the student facing documents

    • I am happy to do this for/with you!

Thanks for considering!

good first issue statuhelp-wanted tracelixir typnew-exercise

All 8 comments

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:

  • splitting a name into the first a last name
  • getting the first letter of each name
  • capitalising and creating the initials
  • combing the name's initials to make J. S. + J. A.
  • using string interpolation on a multiline string to make the ascii art
     ******       ******
   **      **   **      **
 **         ** **         **
**            *            **
**                         **
**     J. S.  +  J. A.     **
 **                       **
   **                   **
     **               **
       **           **
         **       **
           **   **
             ***
              *

@angelikatyborska - The next steps (if you want to keep going with this) are:

  1. make a branch on this repo like elixir-concept-basic-strings to make use of CI tooling. To do that:

    • 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.

  2. Create the examplar solution
  3. From there, you or I can take on the introduction document for the task. The goal of this document is to give enough for a student to chew on, the relevant terms / modules needed for them to use their "google-fu" to be able to solve the problem without directly giving away any solutions

    • A little introduction to strings in Elixir

    • Maybe some examples of string module functions

    • Intro to string interpolation

    • Introduction to multiline strings (heredocs)

  4. The design document is mostly the same information as the information in the first post above
  5. We open a PR to have our introduction/solution/design reviewed at a high level.

@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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ErikSchierboom picture ErikSchierboom  路  6Comments

ErikSchierboom picture ErikSchierboom  路  3Comments

ErikSchierboom picture ErikSchierboom  路  6Comments

tehsphinx picture tehsphinx  路  4Comments

wolf99 picture wolf99  路  5Comments