Ability to get index number in combine block

I wasn't sure if this should go in feature requests or help with Snap!, but in the image block, there's an option to have an 'index' upvar that tells you the current item index. I would like to request that there be a similar feature in the image block. I tried using 'map' instead, but it just got too messy.


Yeah, but it could still do something like
(replacing foo and bar with the most appropriate names for the two inputs.)

wouldn't you want the index for both of the items in that case?

Oh. Maybe it would just return the index for the first one, since that seems most useful and easy to build upon
Afaik, you could just do something like image

I'm not sure you consider it simple ...
untitled script pic (42)
or without extra var
untitled script pic (43)

All you guys are misunderstanding how COMBINE works. There's no "both of the items." The combining function is called with the result so far as one input and one item from the input list as the other. (The first call to the combining function is an exception; it does have two items as inputs.)

Also, you should note that we carefully do not specify whether the combining happens left to right (what you'd expect from an iterative implementation) or right to left (what you'd expect from a recursive implementation). Instead we specify that the combining function has to be associative, i.e., it has to not care about which order is used. (Common Lisp provides both orders, with HOFs named FOLDL and FOLDR.)

So I'm guessing that @helicoptur is abusing COMBINE for something that should be done using a different tool. :~)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.