Skip to content

Mapping over an array #79

Closed Answered by RCHowell
rajivr asked this question in Q&A
May 18, 2024 · 4 comments · 3 replies
Discussion options

You must be logged in to vote

For you question, this is closed.

I am trying to figure out the correct way to map over an array using PartiQL

Answer

-- Mapping values of an array `elements` by applying `fn`

-- Kotlin:   elements.map { e -> fn(e) }
-- Rust:     elements.map(|e| fn(e))
-- Python:   fn(e) for e in elements


SELECT VALUE fn(e) FROM elements AS e

If you want to start a discussion about the specification, please open another topic with the relevant title. I hope we can get some traction on updating the spec to preserve ordering in the FROM clause.

For reference

Normally 𝑎 is a collection, i.e, an array [𝑒0,...,𝑒𝑛−1] or a bag <<𝑒0,...,𝑒𝑛−1>>. In e…

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@rajivr
Comment options

Comment options

You must be logged in to vote
2 replies
@rajivr
Comment options

@RCHowell
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by rajivr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants