Selectively apply function

Given a list of curves which are derived from mep pipes. Some of those curves need to be reversed based on an instance parameter in the original pipes. List composition need to be preserved. How would one achieve that? I am trying to make a to apply based on a boolean mask, but no success yet.

I am trying something like this:

I solved the problem by writing my first python script node with a simple for loop with an if which replaces values based on a mask:

#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
original = IN[0]
modified = IN[1]
mask = IN[2]

for n,i in enumerate(original):
if mask[n] == True:
#Assign your output to the OUT variable.
OUT = original

This is inefficient, because the modified list is created fully beforehand. More efficient approach would be to determine which elements would need to be modified and then modify only them.

Does anyone know how to insert code in this forum properly? Can’t find any guidelines.

You can reverse the curves in your script, using DSCoreNodes library. I copy and paste the code in Word, then here and click on the [ ] button.

import clr
import DSCore
from DSCore import *
original = IN[0]
mask = IN[1]
output = []
for a, i in enumerate(original):
    if mask[a] == 1:
OUT = output

Hi Thank you very much for your suggestion. Do you think it is possible to design the script so that it becomes a general method? Like or other nodes where you supply a function which is executed on, in this case, the elements that pass the mask. Ive read tho that supplying functions to python is not possible atm ( migration guide for 6 -> 7. Maybe the name of the node could be supplied as a string and then converted to a function call for that node inside of python?