Map Function
Issue #221
resolved
Assume I have 2 repeat objects like below.
<O N="D" T="DesignCode">
<O N="D1" T="Repeat" S="0" E="10" I="1" CTRL="ii" ii="0">
<O N="D2" T="Repeat" S="0" E="10" I="1" CTRL="jj" jj="0">
<P N="Fu" V="jj*ii" />
</O>
</O>
<P N="mappedFu" V="map(D1[2].D2, Fu)" />
</O>
mappedFU returns to 0,0,0,0,0... Is this expected behavior?
https://openbrim.appspot.com/objidqotp711gmktkzp8qcgs0w95wj2.libobj
I would like to map all Fu parameters to a list but couldn't figure out. Is it possible to show me an example?
Comments (5)
-
-
- changed status to open
a new function allowing us to collect a list of objects or parameters by name inside an object (or root project object by default).
-
As of v3.17.0115, you can use params() and objs() functions to create a list of parameters or objects. Documentation is pending, but here is how you can handle your case. Change the value of mappedFu to:
<P N="mappedFu" V="params('Fu')" />
Let me know if this does not solve your issue.
-
reporter this is resolved, thanks
-
- changed status to resolved
- Log in to comment
It is really hard to say what the behavior is supposed to be in this case, but I can see what you are trying to do. I think we need a new function for this.
Note that you have multiple parameters named Fu here -- that is what Repeat object implicitly do. It repeats and hence generates multiple instances of its content. If we have a function that can take the values of all parameters named Fu, or all objects named a certain name (while in your example there is no object inside the repeat, you could), then you would be able to get the list of numbers you want.
I will keep this open to track the implementation of this new function.