Jump to content

fizzlesticks

Member
  • Posts

    1,196
  • Joined

Awards

This user doesn't have any awards

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

1,954 profile views
  1. scores[k] is a double. You can't dereference a double.
  2. You can use anything you would would use in a normal if statement. if wkd[1] == 'Sunday' or wkd[1] == 'Saturday' or if wkd[1] in ('Sunday', 'Saturday')
  3. You use things that don't need indenting. For example here's elpiops answer in 1 line: print(dict((lambda d: (d, [d[name].add(item) for name, item in [("Thomas", "pen"), ("Mike", "pencilcase"), ("Thomas", "rubber"), ("Tom", "scissors")]])[0])(__import__('collections').defaultdict(set))))
  4. Anything that can be written in Python can be written in 1 line, it might look silly sometimes though.
  5. Hashed, not encrypted. It could be encrypted, though that's almost as bad as plain text. Yes, many website store your last X passwords so you can't reuse them. They're still hashed and if they're not your current password that shouldn't be a problem.
  6. std::deques have tons of overhead and are inefficient in how they store data compared to a std::vector. For a smallish program like you'll never be able to notice the difference but it's something to keep in mind for other things. std containers have constructors that can do this work for you. std::deque<std::string> uMathCont(std::cbegin(uMathInput), std::cend(uMathInput)); However when you iterate over the input string you're iterating over characters not strings, so it should really be std::deque<char>. edit: if you're using a c++17 compatible compiler (which you should be!) you can let the compiler figure that out for you and just write std::deque deq(std::cbegin(uMathInput), std::cend(uMathInput)); std::endl isn't just a way to write a newline character, it also forces a flush which can have a huge impact on performance (again not really noticeable in a small program like this.) For more a bit more info on that you can check out these 2 videos https://www.youtube.com/watch?v=GMqQOEZYVJQ https://www.youtube.com/watch?v=lHGR_kH0PNA Lastly when posting code please copy/paste into code tags instead of taking a picture.
  7. std::getline Should pretty much not be used. Unless you plan on allowing equations that are millions of characters long std::vector will be better in every way (even push_front.)
  8. Check out java.util.function, they have ways of doing the same thing. There's not really anything "non OOP" about storing then calling a function pointer.
  9. What language do you usually use? Pretty much every popular language has some kind of function pointer like thing that works just like this.
  10. object.bar is just a normal object. It has a __call__ member function that gets invoked when you call object.bar(). So object.bar() calls the object.bar object. Libraries like pyqt need the reference to the object so they are able to invoke it whenever they need to. If you try passing object.bar() to set a listener your giving qt whatever the bar() method returns instead of the bar object itself.
  11. You can get the input as a string and convert it yourself using the stoi function or using a stringstream to convert it in a way similar to cin.
  12. Don't mix input methods. Use getline everywhere.
×