#Problem with maps..

21 messages · Page 1 of 1 (latest)

wispy roost
#

it doesnt think that 'j' is variable that is iterating through map

vague vine
#

why not do j->second()?

#

. has higher precedence than * iirc

#

so its doing *(j.second) isntead of (*j).second

#

u can also use a range based loop

#

this should work too ```cpp
for (auto a : str)
m[a]++;
for (auto a : m)
{
p += a,second / 2;
solo += a.second % 2;
}

rancid fulcrum
#

(also should be j->second, since you're trying to access a data member of a pair)

rancid fulcrum
vague vine
#

fixed

rancid fulcrum
#

👍

vague vine
#

u can even do ```cpp
for (auto [k, v] : m)
{
p += v / 2;
solo += v % 2;
}

#

wait lmao do u actually use 3 spaces indentation

wispy roost
#

Thanks!

wispy roost
wispy roost
wispy roost
vague vine
rancid fulcrum
#

those can be used outside of loop syntax

#

and can be quite handy to get all elements in a pair/tuple/tuple-like

livid pythonBOT
#

@wispy roost

This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.