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 flatten function #684

Merged
merged 5 commits into from
Jul 15, 2024
Merged

add flatten function #684

merged 5 commits into from
Jul 15, 2024

Conversation

OlgaNovg
Copy link
Contributor

closes #672

}
ret := flatten(v)
size = uint(len(ret))
return ret, size, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! As flatten creates a new array it makes sense to safe from uncontrolled grow.

@@ -359,3 +359,17 @@ func median(args ...any) ([]float64, error) {
}
return values, nil
}

func flatten(arg reflect.Value) []any {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job! No need to extra .Interface() call. 👍🏻

@@ -689,6 +689,14 @@ Concatenates two or more arrays.
concat([1, 2], [3, 4]) == [1, 2, 3, 4]
```

### flatten(array) {#flatten}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@antonmedv antonmedv merged commit 5e660e7 into expr-lang:master Jul 15, 2024
12 checks passed
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.

Add flatten() builtin
2 participants