bob@bob
something@something something@something.com
// ChaiScript supports normal functional programming paradigms, with automatic overload resolution | |
var plus = `+` // get a reference to the function object representing all known `+` functions | |
print(plus("a", "b")) // prints "ab" | |
print(plus(1 , 3)) // prints "4" | |
// print(plus("a" , 3)) // generates a runtime error, no string + int operator available | |
// Back ticks are only necessary for capturing operator functions |
#include <tuple> | |
#include <iostream> | |
#include <typeinfo> | |
template<typename Ret> | |
struct function_type | |
{ | |
}; | |
template<typename Ret> |
#include <chrono> | |
#include <string> | |
#include <sstream> | |
#include <vector> | |
#include <iostream> | |
std::vector<std::vector<std::string>> classic(const int num_vecs, const int vec_size) | |
{ | |
std::vector<std::vector<std::string>> retval; |
var func = fun(){ | |
var ret = 0; | |
for (var i = 0; i < 1000000; ++i) { | |
ret += i; | |
} | |
return ret; | |
} | |
// async takes a 0 parameter function object which is run asynchronously and | |
// returns a Boxed_Value (ie, any value, including void, should work) |
// Generator class | |
class Generator | |
{ | |
var has_value; | |
var value_holder; | |
var params; | |
var func; | |
// empty Generator - no value contained |
bob@bob
something@something something@something.com
repositories: | |
- "ChaiScript/ChaiScript" |
#include <vector> | |
int main() | |
{ | |
// initialize a vector of integers. For the purposes of this example let's assume we *need* a vector | |
std::vector<int> v {1, 2, 3, 4, 5, 6, 1012, 1094}; | |
} |
#include <vector> | |
#include <string> | |
#include <sstream> | |
#include <iostream> | |
template<typename ... T> | |
std::vector<std::string> to_strings(const T& ... t) | |
{ | |
std::stringstream ss; | |
return { (ss.str(""), ss << t, ss.str())... }; |
// ChaiScript supports the normal kind of control blocks you've come to expect from | |
// C++ and JavaScript | |
if (5 > 2) { | |
print("Yup, 5 > 2"); | |
} else if (2 > 5) { | |
// never gonna happen | |
} else { | |
// really not going to happen |