Here's where you went wrong:

Map<Opportunity> salesParticipants = new Map<Opportunity>();

Maps need to have two data types, one for the Key, and one for the Value.

Map<Id, Opportunity> salesParticipants = new Map<Id, Opportunity>();

It seems to me you're confusing List/Set and Map, since you're also trying to use "add"; the Map type uses "put" instead.

Finally, it seems that you're really just trying to map one Id to another, so you probably meant:

Map<Id, Id> salesParticipants = new Map<Id, Id>();
for(Opportunity oppy : newMap.values()) {
    if(oppy.Sales_Participant_1__c != null && oldMap.get(oppy.Id).Sales_Participant_1__c != oppy.Sales_Participant_1__c) {
        salesParticipants.put(oppy.Id, oppy.Sales_Participant_1__c);
    }
}
Answer from sfdcfox on Stack Exchange
Top answer
1 of 3
5

Here's where you went wrong:

Map<Opportunity> salesParticipants = new Map<Opportunity>();

Maps need to have two data types, one for the Key, and one for the Value.

Map<Id, Opportunity> salesParticipants = new Map<Id, Opportunity>();

It seems to me you're confusing List/Set and Map, since you're also trying to use "add"; the Map type uses "put" instead.

Finally, it seems that you're really just trying to map one Id to another, so you probably meant:

Map<Id, Id> salesParticipants = new Map<Id, Id>();
for(Opportunity oppy : newMap.values()) {
    if(oppy.Sales_Participant_1__c != null && oldMap.get(oppy.Id).Sales_Participant_1__c != oppy.Sales_Participant_1__c) {
        salesParticipants.put(oppy.Id, oppy.Sales_Participant_1__c);
    }
}
2 of 3
2

Take a look at the Apex Developer Guide on Maps:

Maps

A map is a collection of key-value pairs where each unique key maps to a single value. Keys and values can be any data type—primitive types, collections, sObjects, user-defined types, and built-in Apex types. For example, the following table represents a map of countries and currencies:

Country (Key)     'United States'  'Japan'  'France'  'England'  'India'
Currency (Value)  'Dollar'         'Yen'    'Euro'    'Pound'    'Rupee'

Map keys and values can contain any collection, and can contain nested collections. For example, you can have a map of Integers to maps, which, in turn, map Strings to lists. Map keys can contain up to only four levels of nested collections.

To declare a map, use the Map keyword followed by the data types of the key and the value within <> characters. For example:

Map<String, String> country_currencies = new Map<String, String>();
Map<ID, Set<String>> m = new Map<ID, Set<String>>();

If you look at these, and examine the Maps in your method signature, you will see that there should be two types separated by a comma within your angle brackets (<>). You could denote the correct way to write a Map type as Map<T1, T2>, where T1 is the key type and T2 is the value type. That can be a Map<String, String>, Map<Id, Opportunity>, etc. In your declaration, you only have one type specified. There is no such thing as a Map<Opportunity>, because either you didn't specify the key type or you didn't specify the value type.

🌐
Real Python
realpython.com › python-map-function
Python's map(): Processing Iterables Without a Loop – Real Python
July 31, 2023 - If every tuple in your iterable has two items, then function must take two arguments as well. If the tuples have three items, then function must take three arguments, and so on. Otherwise, you’ll get a TypeError.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-pass-multiple-arguments-to-map-function
Python - pass multiple arguments to map function - GeeksforGeeks
July 15, 2025 - Suppose we pass n iterable to map(), ... should have n number of arguments. These iterable arguments must be applied on given function in parallel. In multiple iterable arguments, when shortest iterable is drained, the map iterator will stop. But in case of Python 2, the map iterator will stop when longest sequence is finished. Define a function sum, which returns sum of two numbers. Declaring and initializing lst1 and lst2. Passing sum function, list1 and list2 to map(). The element at index 0 from ...
🌐
Learn Coding Fast
learncodingfast.com › home › python map() function – how to map a function with multiple arguments
Python map() function – How to map a function with multiple arguments | Learn Coding Fast
November 6, 2020 - This partial object behaves like the getSum() function when called, except that instead of having two arguments, it only has one argument – x. This is because the second argument has been replaced with the value 10. Other than that, the partial object behaves like a normal function. We assign this partial object to a variable called partial_func and pass this object and the list1 iterable to the map() function on line 12.
🌐
Python.org
discuss.python.org › ideas
Don't forbid `map(nullary_func)` - Ideas - Discussions on Python.org
April 13, 2024 - map(f, *iterables) calls f with elements from the iterables until one of them runs out of elements. Except when there are zero iterables. That’s forbidden, for no apparent reason. With the above general rule, map(f) would give an iterator infinitely calling f with zero arguments.
🌐
GitConnected
levelup.gitconnected.com › using-the-map-function-in-python-f088fad8788d
Map function in Python. First of all, we analyse the syntax of… | by Amanda Iglesias Moreno | Level Up Coding
July 30, 2019 - To properly use any function or method, it is recommended to first view it just as a black box, understanding the arguments that we provide (inputs) and the return value given by the function (output). The map function takes two arguments: an iterable and a function, and applies the function ...
Find elsewhere
🌐
ClickHouse
clickhouse.com › functions
Map functions | ClickHouse Docs
Tests whether a condition holds for at least one key-value pair in a map. mapExists is a higher-order function. You can pass a lambda function to it as the first argument.
🌐
Salesforce Developers
developer.salesforce.com › forums
DeveloperForce
February 28, 2013 - Here, you specified a key or value of type "list<map<string,double>>" without a second value to the pair.
🌐
ThePythonGuru
thepythonguru.com › python-builtin-functions › map
Python map() function - ThePythonGuru.com
If we pass n sequences to map(), the function must take n number of arguments and items from the sequences are consumed in parallel, until the shortest sequence is exhausted.
🌐
Carnegie Mellon University
cs.cmu.edu › Groups › AI › html › cltl › clm › node143.html
14.2. Concatenating, Mapping, and Reducing Sequences
In addition, map-into can be called with only two arguments (result-sequence and function), while map requires at least three arguments. If result-sequence is nil, map-into immediately returns nil, because nil is a sequence of length zero. [Function] some predicate sequence &rest more-sequences ...
🌐
Miguendes
miguendes.me › how-to-pass-multiple-arguments-to-a-map-function-in-python
Python: Using the map() Function With Multiple Arguments (2021)
November 28, 2020 - If we take a closer look at map()'s ... iterable, ...). ... If additional iterable arguments are passed, function must take that many arguments and is applied to the items from all iterables in parallel....
Top answer
1 of 2
2

It would be best to provide expected output explicitly, but I think I understand, and maybe something like this would work. I've created a dummy function just for explicitness:

fn[_] := Array[x, {2, 2}];

Append @@@ Comap[{fn, Max}] /@ testlist
(* {{{x[1, 1], x[1, 2]}, {x[2, 1], x[2, 2]}, Max[a, b]}, 
    {{x[1, 1], x[1, 2]}, {x[2, 1], x[2, 2]}, Max[c, d]}, 
    {{x[1, 1], x[1, 2]}, {x[2, 1], x[2, 2]}, Max[e, f]}} *)

Or maybe you wanted the append-ing to happen at the lower level:

Apply[Map[Append[#2], #1] &] /@ Comap[{fn, Max}] /@ testlist
(* {{{x[1, 1], x[1, 2], Max[a, b]}, {x[2, 1], x[2, 2], Max[a, b]}}, 
    {{x[1, 1], x[1, 2], Max[c, d]}, {x[2, 1], x[2, 2], Max[c, d]}}, 
    {{x[1, 1], x[1, 2], Max[e, f]}, {x[2, 1], x[2, 2], Max[e, f]}}} *)

Per the comment, if the desire is to simply avoid computing max twice, then just wrap the expression that already works with With:

With[
  {max = Max[#]},
  Append[{max}, f[max]]] & /@ testlist
2 of 2
1

To address the update to the question, here is a function that does the work (assuming yourFunction behaves like FactorInteger)

MapApply[Append]@*Thread@*Comap[{yourFunction, Identity}]@*Max

Demonstration:

testlist = {{100, 200}, {300, 400}, {500, 600}};
expected = {{{2, 3, 200}, {5, 2, 200}}, 
            {{2, 4, 400}, {5, 2, 400}}, 
            {{2, 3, 600}, {3, 1, 600}, {5, 2, 600}}};

oldFn = FactorInteger;
newFn = MapApply[Append]@*Thread@*Comap[{oldFn, Identity}]@*Max;

actual = newFn /@ testlist;

actual == expected
(* True *)

You could bundle this up into your own function generator:

fancy[fn_] := MapApply[Append]@*Thread@*Comap[{fn, Identity}]@*Max;

actual = fancy[FactorInteger] /@ testlist;
actual == expected
(* True *)
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › map
Array.prototype.map() - JavaScript | MDN - Mozilla
parseInt is often used with one argument, but takes two. The first is an expression and the second is the radix to the callback function, Array.prototype.map passes 3 arguments: the element, the index, and the array. The third argument is ignored by parseInt — but not the second one!
🌐
GitHub
github.com › python › cpython › issues › 119793
Add a "strict" option for map() · Issue #119793 · python/cpython
May 30, 2024 - These two examples silently truncate the unmatched inputs: >>> list(map(pow, [1, 2, 3], [2, 2, 2, 2])) [1, 4, 9] >>> list(map(pow, [1, 2, 3, 4, 5], [2, 2, 2, 2])) [1, 4, 9, 16] The current workaround is: starmap(pow, zip(vec1, vec2, stri...
Published   May 30, 2024
Author   rhettinger
🌐
Julia Language
docs.julialang.org › en › v1 › manual › functions
Functions · The Julia Language
The do x syntax creates an anonymous function with argument x and passes the anonymous function as the first argument to the "outer" function - map in this example. Similarly, do a,b would create a two-argument anonymous function. Note that do (a,b) would create a one-argument anonymous function, whose argument is a tuple to be deconstructed.
🌐
Stackoom
stackoom.com › en › question › 4UknO
python - map must alteast have 2 argument - STACKOOM
Related Question argument 2 to map() must support iteration TypeError: argument 1 must have a “write” method TypeError argument must be an int or have a fileno() method python argument 1 must have a write method Scrape Google map provide these error invalid argument: 'URL' must be a string Python - TypeError: argument must have one “Write” method TypeError: argument 1 must have a “write” method — creating csv from dict TypeError: argument 1 must have a “write” method when running program How to fix 'TypeError: float() argument must be a string or a number, not 'map'' executor.map() TypeError: zip argument #2 must support iteration