Hi,
I am not sure if it’s normal behaviour, an incorrect syntax or a bug, but I find this a little confusing.
Below is a script with 5 ways to cap values from a list to a maximum of 20.
- Option (1): Working.
- Option (2): Why is it returning the full list when the condition is false ?
- Option (3): Working
- Option (4): Why is this returning null ?
- Option (5): Why a warning and null ?
I am using Dynamo 0.8
Kind Regards,
Mehdi
- “x” is a list, you’ve specified that you want the return to be “x” and therefore you get a list.
4)The List.Map node expects a function, The only way to make the DS code to act as a function is to convert it to a custom node.
- You forgot to connect your list “x” to the input of the node?
Mehdi, item no. 2 is a replication issue. It used to work at some point in Dynamo 0.7 but has been broken for some time (https://github.com/DynamoDS/Dynamo/issues/3106). And yes, I think you are right about item no. 5 being the same as item no. 4 - if you wrap the CBN in a custom node it should probably work.
Hi Mehdi,
Sorry about 5); I didn’t see the list.map node.(it was too early in the day for me). But yes, same thing applies as in condition 4). You’ll need to wrap the DS code into a custom node.
About condition 2), to be honest guys I’m not entirely sure if associative DS code should be able to process a list like that in the first place because logically if your input and output use the same variable name and that variable is a list, the return should be the list as well. If you want each item of the list to be processed and returned individually, it might be preferable to use the function node or make your code imperative.
Thanks Andreas and Dimitar.
In regards with condition 2, either associative DS code can process a list (which seems to be a good thing) or they don’t. The conditional statement is halfway in between at the moment because the condition does but the return statement doesn’t.
If you get a chance could you provide me with a similar example using imperative code ?
Mehdi,
I had a quick glance at this again and as it turns out, we don’t need to iterate through the list. As long as you clearly define how the inputs should be treated, you can use associative code as well. Have a look at the below example. In the first case I sate that “a” should be treated as a single entity and in the second I specify that it’s a list. Based on that, the output reflects the input choices: