So I wanted to add a library that worked similarly to LINQ in my language.
And in order to do so I needed to be able to create lambda functions.
//c++ lambda
string a = "hello"
string b = "world!"
auto lambda_func = [a, b] (string c) {
    cout >> a >> c >> b >> "\n"
}
lambda_func(" ")
So I set out to create something that fit my syntax better and this is what I came up with.
//halppp lambda
let a = "hello"
let b = "world!"
> lambda_func a, b (string c) do println($"{a}{c}{b}")
//or multiline
> lambda_func a, b (string c)
    println($"{a}{c}{b}")
;
lambda_func(" ")
So now I was able to create something like linq
vector<int> a = {1,2,3,4,5,6,7,9,10}
> over_five (int i) doremi i > 5
> as_string (int i) doremi $"{i}"
let collection = linq::take(a)
     .where(over_five)
     .operate<string>(as_string).as_vec()
You can still use the c++ style if you want to and if you want to declare it inside the function you still have to use the c++ style.
let lambda_func = [] (int i) {println(i); return i;}
//inside function
linq::range(1000)
    .operate<int>([](int i){println(i); return i;})
 
     
                                
Comments (0)