• Ephera
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 day ago

    During the parsing step, you check that the list has at least one element. If it does not, you report an error to the user and exit. If it does, you take the first element in the least and store it in the left side of your tuple, and then the remaining elements of the input list go into the right side of your tuple.

    So, for example: [1, 2, 3] → (1, [2, 3])
    Or also: [1] → (1, [])
    If the user gives you [], then you cannot represent that with your tuple, you necessarily have to error.