Replies: 2 comments
-
Isn't that what the pipe operator is for?
|
Beta Was this translation helpful? Give feedback.
0 replies
-
That's not a bad suggestion, thanks! But after noodling around a bit, I think I like |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Suppose I have an array
fruit := ['apples', 'oranges', 'pears', 'bananas', 'mangoes']
and an arrayIX := [1,3,0,3]
and I'd like to indexfruit
by each element ofIX
to get['oranges', 'bananas', 'apples', 'bananas']
. What's the nicest/most Civetitious way to do this?I've thought of
IX.map ($) => fruit[$]
but there it's sort of annoying that I can't just doIX.map fruit[&]
(at least not unless there's some motion on #480). Also, this seems to put the emphasis on IX when conceptually fruit is more the "subject of this sentence." I'd rather write something more along the lines offruit[IX]
although of course I know that doesn't work. There isn't any notion for this sort of "random-access slice," is there? From the perspective of emphasizing the fruit,[0...IX.length].map ($) => fruit[IX[$]]
is kind of better, but it's sort of verbose/klunky, too, and I imagine a bit less efficient if I am doing a big case of this.So at the moment I am just doing:
and then writing
fruit by IX
. Have I missed anything nicer?Beta Was this translation helpful? Give feedback.
All reactions