import static io.vavr.API.*;
class Main {
public static void main(String... args) {
println("Hello Vavr!");
}
}
- Download npm and node
- echo "console.log('Hello world');" > index.js
- node index.js
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
const f = require('./module.js'); | |
const g = require('./module.js'); | |
console.log("f()", f()); // = f() 0 | |
console.log("g()", g()); // = g() 1 | |
const path = require('path'); | |
delete require.cache[path.resolve(__dirname, 'module.js')]; | |
const h = require('./module.js'); | |
console.log("h()", h()); // = h() 0 |
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
var fizzbuzz = Stream.of("", "", "Fizz").cycle() | |
.zipWith(Stream.of("", "", "", "", "Buzz").cycle(), String::concat) | |
.zipWith(Stream.from(1), (s, i) -> s.isEmpty() ? i.toString() : 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 splitUrl(url) { | |
const parts = url.match(/^(http[s]?):\/\/([^:/]*):?(\d*)\/?(.*)$/i); | |
if (parts === null) { | |
throw Error('invalid url: ' + url); | |
} else { | |
return { | |
protocol: parts[1], | |
host: parts[2], | |
port: parts[3], | |
path: (parts[4] === '') ? '' : ('/' + parts[4]) |
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
import io.vavr.collection.Iterator; | |
import io.vavr.collection.Seq; | |
public class Test { | |
public static void main(String[] args) { | |
int size = 10; | |
Iterator<String> iter = Iterator.continually(() -> (char) (Math.random() * ((122 - 48) + 1) + 48)) |
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
Seq<Tuple<Integer, Integer>> getSubstringPalindromes(String s) { | |
final N = s.length(); | |
return List.range(0, N-1) | |
.flatMap(i -> List.of(Tuple.of(i, i+1), Tuple.of(i, i+2))) | |
.flatMap(t -> List.unfold(t, tt -> { | |
final int i = tt._1; | |
final int j = tt._2; | |
return i >= 0 && j <= N && isPalindrome(s.substring(i, j)) | |
? Option.some(Tuple(i-1, j+1), tt) | |
: Option.none(); |
How do I dropdown?
This is how you dropdown.<details>
<summary>How do I dropdown?</summary>
This is how you dropdown.
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
Verifying that "danieldietrich.id" is my Blockstack ID. https://onename.com/danieldietrich |