| 123456789101112131415161718192021222324252627282930 |
- #include <luwra.hpp>
- #include <iostream>
- static
- double sum3(int a, int b, double c) {
- return (a + b) * c;
- }
- int main() {
- luwra::StateWrapper state;
- state.loadStandardLibrary();
- // Build stack
- luwra::push(state, 13);
- luwra::push(state, 37);
- luwra::push(state, 42.2);
- // Each value can be retrieved individually.
- std::cout << "a = " << luwra::read<int>(state, 1) << std::endl;
- std::cout << "b = " << luwra::read<int>(state, 2) << std::endl;
- std::cout << "c = " << luwra::read<double>(state, 3) << std::endl;
- // ... which is a little cumbersome. Instead we might apply a fitting function to our stack.
- std::cout << "(a + b) * c = "
- << luwra::apply(state, sum3)
- << std::endl;
- return 0;
- }
|