Lambda functions Spice allows you to create lambda functions. Lambda functions are anonymous functions that can be used as values. They are useful for e.g. passing callback functions as parameters into other functions. Usage¶ Lambdas in Spice work like this: Procedure lambdas¶ Spice1 2 3 4 5 6// Definition p(int, double) lambda = p(int a, double b) { printf("Lambda was called with %d and %f", a, b); }; // Call lambda(5, 3.14); Function lambdas¶ Spice 1 2 3 4 5 6 7 8 9 10// Definition f<int>(const String&, bool) lambda = f<int>(const String& str, bool b) { if (b) { return str.getLength(); } else { return -1; } }; // Call int result = lambda(String("Hello"), true); Inline lambdas¶ Spice1sort((int x, int y) => x < y);