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 axis operator #105

Open
jjg-123 opened this issue Mar 17, 2025 · 0 comments
Open

Add axis operator #105

jjg-123 opened this issue Mar 17, 2025 · 0 comments

Comments

@jjg-123
Copy link
Collaborator

jjg-123 commented Mar 17, 2025

Scott's observation is that the built-in for_each function should intuitively allow for operating like a map functor (in functional programming languages, map applies an operator every element of a list). Since QDL has a very general concept of stem, this means that some way to communicate this needs to be done.

Therefore, a backtick, `, now can be used to restrict the for_each to a given axis. The idea is that at that axis, every entry for the stem is treated as a unit and simply passed. If

a. := [[1,2,3], [4,5,6], [7,8,9], [10,11,12]]
Then to loop over the 4 elements and apply your function f you would issue

for_each(@f, a.`0)

yielding

[f(a.0). f(a.1), f(a.2), f(a.3)]

cf.
for_each(@f, a.); // no axis specified

yields the 3x4 array

[ [f(a.0.0), f(a.0.1). f(a.0.2), ...]]

jjg-123 added a commit that referenced this issue Mar 17, 2025
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

1 participant