Stuck on list pocessing

Hello,

I am stuck on getting the following to work on a list. I’ve tried all sorts of things with List.Map and List.Combine, but nothing seems to work. Any ideas? I want to be able to pass the list shown at the top of the code block to get the individual results when passing each item one by one. Any help would be greatly appreciated! Thanks.

ListProcessing

My apologies for the typo in the topic name, which should read "Stuck on list processing, but the Edit functionality doesn’t seem to be working.

I have no clue why that is not working, but here’s and alternate solution…

ListSolution

 

First, once you have the logic figured out for one case, you can always apply it to multiple cases by making a custom node (or a function in a code block) and then using List.Map.

But here is a fancier trick. First, solve it for one case (top row). Then write a function in a code block to do the same thing (bottom row). The function in the code block is effectively the same thing as a custom node except that it doesn’t introduce a new file dependency. The real trick is to specify that the listB act on an item at a time (the “var” part) and the listA should act on a full list of items (the “var” part).

FindFirstLarger

FindFirstLarger.dyn

Thanks Ben and Colin! I’m going to digest. Colin’s approach requires a bit more time for it to sink in. I’m also going to see if I can go the custom node route. I’ve already tried several things this morning but nothing worked, hence why I posted here for help. Will report back, thanks again!

Finally got it. List processing and function structures are kicking my bee-hind!

BTW Colin, that’s been my strategy lately when it comes to this sort of thing. I get things working with one item compared to a list for example, then I reformat to get it to work with two lists. But I seem to spend more time getting that to work than the original quest. I’ll continue digesting your CBN example. Thanks again.

Solution

Cool.

Just curious (maybe Colin can shed some light), but how did you know which list would go to “x” and which would go to “y” in the <= node? Seems like Dynamo is free to choose in the list.Map node where the “To Compare” list goes, or does it always go to the first available input? So in this case, the “To Compare” list goes to X first, then the “Target List” goes to y since it comes in later down the line…

Rhyme and reason

That’s exactly what confuses me about functions like this with multiple input ports. To be honest with you, I had a hard time understanding how and why it works, especially because I wasn’t actually understanding what the MaximumItemByKey node does. I think it should actually be renamed to “FirstItemByKey” because it picks the first item in the list that satisfies the function. I also think it has a bug because if no item satisfies the criteria, it returns the first item in the list, whereas I think it should return -1 or null. It also needs a description.

Here is how I was able to explain the above to myself. In the process I also understood what MaximumItemByKey is actually doing. Hope this helps.

MaximumItemByKey

Check out my explanation on “MaximumItemByKey” here:

If you want to be able to process the Booleans resulting from the <= operator, your graph should resemble something like this:

2015-07-24_12-22-40