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

Add support for arrays #170

Open
blaumeise20 opened this issue Oct 1, 2020 · 1 comment
Open

Add support for arrays #170

blaumeise20 opened this issue Oct 1, 2020 · 1 comment

Comments

@blaumeise20
Copy link

blaumeise20 commented Oct 1, 2020

We should add support for arrays! They would allow us to create complex structures.

Changes:

Restructure for loops to iterate over an array:

for <variableName> of <array> 
{
}

to would create an array:

var nums: int[] = 1 to 10
for i of nums
{
}

Function array(length: number): any[]:

let list: string[] = array(5)

To make that possible we would also have to implement nulls (#171)
Function count(list: any[]): int

let length: int = count(list)

New syntax [0, 1] to create initialized arrays (automatically detect types):

let list2 = [1, 2, 3, 4, 5] // I know, you could use 1 to 5 here

New syntax list[i]:

let value = list2[2] // = 3

That would allow us to create such functions:

function prompt(questions: string[]): string[]
{
    let result: string[] = array(count(questions))
    var index = 0;
    for q of questions
    {
        print(q)
        result[index] = input()
        index++ // I think we already have that
    }
    return result
}
@blaumeise20 blaumeise20 mentioned this issue Oct 1, 2020
@HirushaR
Copy link

HirushaR commented Nov 1, 2020

Does someone working on arryas

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

No branches or pull requests

2 participants