Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple-linked-list: add canonical data #1974

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

loziniak
Copy link
Member

@loziniak loziniak commented Mar 2, 2022

references #568 and #587

@angelikatyborska
Copy link
Contributor

I am a bit surprised by the property names you're suggesting in this PR, fromArrayAndBack and convertReverseConvertBack? Did you base that on some existing implementation of this exercise?

I'm looking at the implementations from some of the most popular tracks:

They all include push and reverse, two of them also pop. Should those properties be part of the problem specification?

I think the challenge in writing problem specs for this exercise is to choose some representation of linked lists that will be different from a JSON array, to be able to write specifications for properties something like fromArray and toArray. I'm looking at the problem specification of linked-list (https://github.com/exercism/problem-specifications/blob/main/exercises/linked-list/canonical-data.json) and there the problem is worked around by only specifying chains of operations that result in an empty list 🤔.

I'm not really sure what should happen in problem specs for this exercise but I wanted to kick off a discussion so that this PR doesn't go ignored. @exercism/reviewers anyone would like to chime in?

@loziniak
Copy link
Member Author

loziniak commented Mar 8, 2022

I suggested these methods as an indirect way of testing methods, that are subject of the exercise:

"lets create a singly linked list to contain the range (1..10), and provide functions to reverse a linked list and convert to and from arrays." (problem description)

To test function that creates a list from an array, we should encode somehow a linked list in JSON to check it by expected field in canonical data, same with reverse function, there a list should also be an input. I had no idea how to do this.

fromArrayAndBack is simply a superposition of fromArray and then toArray. And convertReverseConvertBack is fromArrayreversetoArray. You can see the idea in my example solution in Red track. Now I think perhaps it's a good idea to add a track-specific notice about this anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants