lambda - Java 8 Pattern Matching? -
will java 8 support pattern matching scala , other functional programs do? i'm putting presentation of java 8's lambda features. can't find on particular functional-programming concept.
i remember got me interested in functional programming quicksort implementation, compared imperative programming's implementation.
i suppose not talking pattern matching in sense of applying regular expression on string, applied in haskell. instance using wildcards:
head (x:_) = x tail (_:xs) = xs
java 8 not support natively, lambda expression there are, however, ways so, computing factorial:
public static int fact(int n) { return ((integer) new patternmatching( incaseof(0, _ -> 1), otherwise( _ -> n * fact(n - 1)) ).matchfor(n)); }
how implement find more information in blog post: towards pattern matching in java.
Comments
Post a Comment