DB48X-on-DM42 icon indicating copy to clipboard operation
DB48X-on-DM42 copied to clipboard

Extracting list elements into local variables

Open c3d opened this issue 2 years ago • 1 comments
trafficstars

Add a syntax to extract list or array elements into local variables.

The proposed syntax to extract list elements would be:

« → { A B C }
    «
        A B + C -
    »
»

And for array elements:

« → [ A B C ]
    «
        A B + C -
    »
»

The above two examples would only accept fixed-size lists and array (3 elements in the examples).

Another syntax extension would let the last variable take "the rest":

« → { A B C * }
    «
        A B + C
    »
»

Given { 1 2 3 4} as input, this would extract 1 and 2 in A and B, and put the (possibly empty) rest in C, in that case { 3 4 }.

c3d avatar Jul 18 '23 07:07 c3d

This could be complemented with a facility to build structured lists:

   "Informagie"
   "Christophe de Dinechin"
   "How dinosaurs save humanity"
   "https://www.amazon.fr/dp/B07Z4XJ4Y9"
    { title author subject bookid } →TaggedList

would produce this list of tagged items:

{
    title:"Informagie"
    author:"Christophe de Dinechin"
    subject:"How dinosaurs save humanity"
    bookid:"https://www.amazon.fr/dp/B07Z4XJ4Y9"
}

There could be →Struct and Struct→ variants to manipulate such lists.

c3d avatar Jul 18 '23 08:07 c3d