# Addition Assignment

**URL:** <https://forum.canton.network/t/addition-assignment/1459>\
**Category:** App Development\
**Created:** [October 13, 2020, 4:36pm UTC](https://forum.canton.network/t/addition-assignment/1459 "2020-10-13T16:36:58Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Stephen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stephen/32/102_2.png) [@Stephen](https://forum.canton.network/u/Stephen)\
**Post date:** [October 13, 2020, 5:49pm UTC](https://forum.canton.network/t/addition-assignment/1459/5 "2020-10-13T17:49:42Z")

</div>

There is a good chance that `forA` is not the function you want to use here. That’s because the function you pass to it is only allowed to depend on the argument (`quantity`), and the only form of “sequence”, or things happening in a particular order, comes from the actions you are performing with the `do`. Specifically, variable binding _is not_ such an action; it is purely a local alias for a value, and cannot escape its scope of definition. (To put it another way, DAML functions must be true functions, whose only “effect” is in accepting arguments and returning values.)

You might be comfortable with `forA` from examples. However, it is not a “one size fits all” function for working across the aggregate of a list; it is used in those examples because it hides some details of lists that are sometimes useful, but not always. If there is any “one size fits all” function for lists, it’s `foldr` or `foldl` as @cocreature [used previously](https://discuss.daml.com/t/delete-multiple-keys-from-map/1287/2), but you won’t see `foldr` in most examples, because it is much nicer in DAML to use a function that more closely fits your use case, and `foldr` is far too powerful and general-purpose for that.

To determine what the proper function to use instead of `forA` is, first decide: are you performing any _actions_ from the function you’re passing in, such as contract exercises or creates? If you are, a good starting point is the `DA.Action` module; if you are not, check the `DA.Foldable` module instead. Regardless, the starting point is to make that determination.

---

_[View the full topic](https://forum.canton.network/t/addition-assignment/1459)._
