Advertisement
pochti_da

Untitled

Mar 14th, 2021
587
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. namespace {
  2.     std::map<std::string, void(*)(complex_stack &)> op = {
  3.         { "+", [](complex_stack &st) {
  4.             complex x, y;
  5.             extract(st, x, y);
  6.             st = st << (x + y);
  7.         }},
  8.         { "-", [](complex_stack &st) {
  9.             complex x, y;
  10.             extract(st, x, y);
  11.             st = st << (y - x);
  12.         }},
  13.         { "*", [](complex_stack &st) {
  14.             complex x, y;
  15.             extract(st, x, y);
  16.             st = st << (x * y);
  17.         }},
  18.         { "/", [](complex_stack &st) {
  19.             complex x, y;
  20.             extract(st, x, y);
  21.             st = st << (y / x);
  22.         }},
  23.         { "!", [](complex_stack &st) {
  24.             complex x = +st;
  25.             st = st << x;
  26.         }},
  27.         { ";", [](complex_stack &st) {
  28.             st = ~st;
  29.         }},
  30.         { "~", [](complex_stack &st) {
  31.             complex x;
  32.             extract(st, x);
  33.             st = st << (~x);
  34.         }},
  35.         { "#", [](complex_stack &st) {
  36.             complex x;
  37.             extract(st, x);
  38.             st = st << (-x);
  39.         }}
  40.     };
  41. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement