This file contains hidden or 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
| pow2 :: Integer -> Integer | |
| pow2 a = a * a |
This file contains hidden or 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
| $(document).ready(fixUrls); |
This file contains hidden or 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 fixUrls(){ | |
| $('a').each(function () { | |
| //get the original URL | |
| var theURL = $(this).attr('href'); | |
| if (theURL.includes('t.umblr.com/redirect?')) { | |
| //split at the equals sign | |
| var one = theURL.split('='); | |
| //split again at the amperstand | |
| var two = one[1].split('&') | |
| //get rif of the URL encoding |
This file contains hidden or 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
| for (int i = 0; i <= 10; i = i + 2) { | |
| System.out.println(i); | |
| } |
This file contains hidden or 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
| Stream.iterate(0, i -> i <= 10, i -> i + 2) | |
| .forEach(System.out::println); |
This file contains hidden or 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
| Stream.iterate(0, i -> i + 2) | |
| .forEach(System.out::println); |
This file contains hidden or 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
| Set<Integer> numbers = Set.of(1, 3, 6, 2, 4); | |
| numbers.stream() | |
| .takeWhile(i -> i < 4) | |
| .forEach(System.out::println) | |
| ; |
This file contains hidden or 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
| Stream.iterate("*", s -> s + "*") | |
| .takeWhile(s -> s.length() < 7) | |
| .forEach(System.out::println) | |
| ; |
This file contains hidden or 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
| object DeathToStrategy extends App { | |
| def add(a: Int, b: Int) = a + b | |
| def subtract(a: Int, b: Int) = a - b | |
| def multiply(a: Int, b: Int) = a * b | |
| def execute(callback:(Int, Int) => Int, x: Int, y: Int) = callback(x, y) | |
| println("Add: " + execute(add, 3, 4)) | |
| println("Subtract: " + execute(subtract, 3, 4)) |
This file contains hidden or 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
| interface Strategy { | |
| int execute(int a, int b); | |
| }; | |
| /** Implements the algorithm using the strategy interface */ | |
| class Add implements Strategy { | |
| public int execute(int a, int b) { | |
| System.out.println("Called Add's execute()"); | |
| return a + b; // Do an addition with a and b | |
| } |