**(altered: // [[harlowe:Lambda|lambda]], ...Any//) -> //[[harlowe:Array|array]]//** This takes a "via" [[harlowe:lambda|lambda]] and a sequence of values, and creates a new [[harlowe:array|array]] with the same values in the same order, but altered via the operation in the lambda's "via" clause. === Example usage: === * ''%%(altered: _monster via "Dark " + _monster, "Wolf", "Ape", "Triffid")%%'' produces ''%%(a: "Dark Wolf", "Dark Ape", "Dark Triffid")%%'' * ''%%(altered: _player via _player + (dm: "HP", _player's HP - 1), ...$players)%%'' produces an array of $players [[harlowe:datamap|datamap]] whose "HP" datavalue is decreased by 1. === Rationale: === Transforming entire arrays or [[harlowe:dataset|dataset]], performing an operation on every item at once, allows arrays to be modified with the same ease that single values can - just as you can add some extra text to a [[harlowe:string|string]] with a single +, so too can you add extra text to an entire array of strings using a single call to (altered:). This macro uses a lambda (which is just the "temp variable ''%%via%%'' an expression" expression) to take each item in the sequence and produce a new value to populate the resulting array. For ''%%(altered: _a via _a + 1, 10,20,30)%%'' it will produce 10 + 1, 20 + 1 and 30 + 1, and put those into a new array. === Details: === Of course, if any operation applied to any of the values should cause an error, such as trying to add a string to a [[harlowe:number|number]], an error will result. An error will NOT appear if you provide no values after the lambda - an empty array will be returned instead. This allows you to write `(altered: $lambda, ...$array)` without checking whether $array contains any values (which you may not be certain of, if it contains the result of a previous [[harlowe:find|(find:)]]). The temp variable, which you can name anything you want, is controlled entirely by the lambda - it doesn't exist outside of it, it won't alter identically-named temp variables outside of it, and you can't manually [[harlowe:set|(set:)]] it within the lambda. You can refer to other variables, including other temp variables, in the ''%%via%%'' expression. For instance, you can write ''%%(altered: _object via _playerName + "'s " + _object, "Glove", "Hat", "Purse")%%''. However, for obvious reasons, if the outer temp variable is named the same as the lambda's temp variable, it can't be referred to in the expression. If no values are given to (altered:) except for the lambda, an empty array will be produced. === See also: === [[harlowe:for|(for:)]], [[harlowe:folded|(folded:)]]