Tuple projections #452

Open
opened 2023-05-13 18:30:55 +09:00 by zxq9 · 0 comments
zxq9 commented 2023-05-13 18:30:55 +09:00 (Migrated from gitlab.com)

Created by: radrow

Tuple projections are awkward, even considering standard library which offers fst, snd etc. for pairs and triples. There should be a convenient generic way of accessing them:

let t = (1, "xd", true, [4,5,6,7])

t[1] + List.length(t[4])

It's to be discussed if we prefer indexing from 0 or 1. For reference, Erlang and Scala do it from 1, while Python and JS prefer 0. Note that computationally it does not matter, because the index has to be a fixed (syntactically) integer due to type consequences.

*Created by: radrow* Tuple projections are awkward, even considering standard library which offers `fst`, `snd` etc. for pairs and triples. There should be a convenient generic way of accessing them: ``` let t = (1, "xd", true, [4,5,6,7]) t[1] + List.length(t[4]) ``` It's to be discussed if we prefer indexing from 0 or 1. For reference, Erlang and Scala do it from 1, while Python and JS prefer 0. Note that computationally it does not matter, because the index has to be a fixed (syntactically) integer due to type consequences.
Sign in to join this conversation.
No Milestone
No project
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: QPQ-AG/sophia#452
No description provided.