Improve Readability of example (#221)

This commit is contained in:
Anurag Bhat 2024-03-04 15:02:16 +05:30 committed by GitHub
parent 1caa9e71c3
commit 4a4eade26f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 6 deletions

View File

@ -91,7 +91,7 @@ int main(){
// Eval the sum of the list
PyObject* result = vm->eval("sum(a)");
std::cout << py_cast<int>(vm, result); // 6
std::cout << "Sum of the list: "<< py_cast<int>(vm, result) << std::endl; // 6
// Bindings
vm->bind(vm->_main, "add(a: int, b: int)",
@ -104,7 +104,7 @@ int main(){
// Call the function
PyObject* f_add = vm->_main->attr("add");
result = vm->call(f_add, py_var(vm, 3), py_var(vm, 7));
std::cout << py_cast<int>(vm, result); // 10
std::cout << "Sum of 2 variables: "<< py_cast<int>(vm, result) << std::endl; // 10
// Dispose the virtual machine
delete vm;

View File

@ -51,7 +51,7 @@ int main(){
// 计算列表元素之和
PyObject* result = vm->eval("sum(a)");
std::cout << py_cast<int>(vm, result); // 6
std::cout << "Sum of the list: "<< py_cast<int>(vm, result) << std::endl; // 6
// 绑定一个函数
vm->bind(vm->_main, "add(a: int, b: int)",
@ -64,7 +64,7 @@ int main(){
// 调用函数
PyObject* f_add = vm->_main->attr("add");
result = vm->call(f_add, py_var(vm, 3), py_var(vm, 7));
std::cout << py_cast<int>(vm, result); // 10
std::cout << "Sum of 2 variables: "<< py_cast<int>(vm, result) << std::endl; // 10
// 释放虚拟机
delete vm;

View File

@ -102,7 +102,7 @@ int main(){
// Eval the sum of the list
PyObject* result = vm->eval("sum(a)");
std::cout << py_cast<int>(vm, result); // 6
std::cout << "Sum of the list: "<< py_cast<int>(vm, result) << std::endl; // 6
// Bindings
vm->bind(vm->_main, "add(a: int, b: int)",
@ -115,7 +115,7 @@ int main(){
// Call the function
PyObject* f_add = vm->_main->attr("add");
result = vm->call(f_add, py_var(vm, 3), py_var(vm, 7));
std::cout << py_cast<int>(vm, result); // 10
std::cout << "Sum of 2 variables: "<< py_cast<int>(vm, result) << std::endl; // 10
// Dispose the virtual machine
delete vm;