Data update

This commit is contained in:
Ingy döt Net 2024-10-16 18:07:41 -07:00
parent 81fd053722
commit 52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions

View file

@ -0,0 +1,27 @@
import java.util.function.BiFunction;
import java.util.function.DoubleUnaryOperator;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.UnaryOperator;
public final class FunctionDefinition {
public static void main(String[] args) {
System.out.println(size.apply("Rosetta"));
System.out.println(greeting.apply("Joe"));
System.out.println(half.applyAsDouble(7));
System.out.println(lessThanTen.test(15));
System.out.println(add.apply(2, 3));
}
private static Function<String, Integer> size = s -> s.length();
private static UnaryOperator<String> greeting = s -> "Hello " + s;
private static DoubleUnaryOperator half = a -> a / 2;
private static Predicate<Integer> lessThanTen = a -> a < 10;
private static BiFunction<Integer, Integer, Integer> add = (a, b) -> a + b;
}

View file

@ -1,2 +1,8 @@
var multiply = (a, b) => a * b;
var multiply = (a, b) => { return a * b };
// Or, `var` being long deprecated, and currying convenient,
// (particularly in use with the higher-order Array methods)
const multiply = a =>
b => a * b;

View file

@ -0,0 +1,5 @@
let prod(a, b) := a*b
let prodAnon := (a, b) -> a*b
assert(prodAnon(2, 2) = ((a, b) -> a*b)(2, 2))
assert(prod(2, 2) = prodAnon(2, 2))

View file

@ -0,0 +1,15 @@
!yamlscript/v0
# Main function definition with variable arguments:
defn main(*args):
say: "multiply($(args.join(', ')))
-> $multiply(args*)"
# A multi-arity function definition:
defn multiply:
(): 1
(x): x
(x y): x * y
(x y *more):
reduce multiply:
multiply(x y) more