This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Predicate<String> notNullNorEmpty = s -> s != null && !s.isEmpty(); | |
Predicate<String> isFull = s -> s.matches("\\S+"); | |
Predicate<String> isIntegral = s -> s.matches("\\d+"); | |
Predicate<String> isDecimal = s -> s.matches("\\d+\\.\\d+"); | |
Predicate<String> isNumeric = isIntegral.or(isDecimal); | |
Predicate<String> notNullNumeric = notNullNorEmpty.and(isNumeric); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function<String, Integer> only3PositiveDigits = s -> { | |
if (!s.matches("\\d{3}") { | |
return -1; | |
} | |
return new Integer(s); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function<String , Integer> only3PositiveDigits = s -> s.matches("\\d{3}") ? new Integer(s) : -1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Supplier<Integer> alwaysOne = () -> 1; | |
alwaysOne.get(); // --> 1 | |
alwaysOne.get(); // --> 1, again | |
alwaysOne.get(); // --> still 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyIndex implements Supplier<Integer> { | |
private int index = 0; | |
@Override | |
public Integer get() { | |
return index++; | |
} | |
} | |
MyIndex i = new MyIndex(); | |
i.get(); // --> 0 | |
i.get(); // --> 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Consumer<String> log = s -> Logger.getGlobal().info(s); | |
Consumer<String> toss = s -> { | |
throw new IllegalArgumentException(s); | |
} | |
Consumer<String> logAndToss = log.andThen(toss); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket/base | |
(require racket/list | |
racket/sequence) | |
(define MAX-OVERWRITE 8) | |
(define overwrite-range (range MAX-OVERWRITE)) | |
(define (get-random-bytes count) | |
(with-input-from-file "/dev/urandom" | |
(λ () (read-bytes count)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System.Text.RegularExpressions | |
open FsUnit | |
open NUnit.Framework | |
let parseLot lot = | |
match lot with | |
| x when Regex.Match(x, @"^\d+$").Success -> [ x |> int ] | |
| x when Regex.Match(x, @"^\d+-\d+$").Success -> | |
let parts = x.Split('-') | |
[ parts.[0] |> int..parts.[1] |> int ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<words> | |
<word>123</word> | |
<word>mom</word> | |
<word>12321</word> | |
<word>madam im adam</word> | |
<word>Mom</word> | |
<word>Madam I'm Adam</word> | |
<word>FooBar</word> | |
<word>Eva, Can I Stab Bats In A Cave?</word> | |
</words> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mvn clean test -Dmunit.test="lambda-test-suite.xml" :( | |
[INFO] Scanning for projects... | |
[INFO] | |
[INFO] ------------------------------------------------------------------------ | |
[INFO] Building Mule dataweave Application 1.0.0-SNAPSHOT | |
[INFO] ------------------------------------------------------------------------ | |
Downloading: http://nexusprod:8080/nexus/content/repositories/releases/org/apache/maven/plugins/maven-install-plugin/maven-metadata.xml | |
Downloading: http://nexusprod:8080/nexus/content/repositories/snapshots/org/apache/maven/plugins/maven-install-plugin/maven-metadata.xml | |
Downloading: http://repository.mulesoft.org/releases/org/apache/maven/plugins/maven-install-plugin/maven-metadata.xml | |
Downloading: http://nexusprod:8080/nexus/content/repositories/thirdparty/org/apache/maven/plugins/mav |
OlderNewer