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
| (unless (getenv "TERM_PROGRAM") | |
| (progn | |
| (setenv "PATH" (shell-command-to-string "source $HOME/.bashrc && printf $PATH")) | |
| )) | |
| (setq exec-path (append exec-path (split-string (getenv "PATH") ":"))) | |
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
| (defun error-ignorable-require (md) | |
| (condition-case err | |
| (require md) | |
| (error nil))) | |
| (defmacro when-mode (modename &rest body) | |
| "Evaluate body when `modename' is require-d successfully. `modename' should not be quoted." | |
| (let | |
| ((mode `',modename)) | |
| `(when |
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
| (defmacro if-let (binding-form when-true when-false) | |
| (destructuring-bind (var-name var-expr) binding-form | |
| `(let ((,var-name ,var-expr)) | |
| (if ,var-name | |
| ,when-true | |
| ,when-false)))) | |
| (macroexpand '(if-let (a 3) | |
| a | |
| (+ a a))) ; => (let ((a 3)) (if a 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
| (let ((a 10)) | |
| (let ((a 200) (b a)) | |
| a ; => 200 | |
| b ; => 10 | |
| ) | |
| (let* ((a 200) (b a)) | |
| a ; => 200 | |
| b ; => 200 | |
| )) |
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
| import java.io.File; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| import java.util.concurrent.ExecutionException; | |
| import java.util.concurrent.ForkJoinPool; | |
| import java.util.concurrent.RecursiveTask; | |
| public class ForkJoinExampleBySummarizeFileSize { | |
| public static void main(String[] args) { |
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
| import java.util.Arrays; | |
| import java.util.stream.Stream; | |
| public class StreamExample { | |
| public static void main(String... args){ | |
| Stream.of("1", "Foo", "2", "Bar", "3") | |
| .filter( | |
| str -> { | |
| // To view stacktrace. | |
| new Exception().printStackTrace(); |
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
| import java.util.Arrays; | |
| import java.util.function.Function; | |
| /** | |
| * Created with IntelliJ IDEA. | |
| * User: owner | |
| * Date: 13/05/06 | |
| * Time: 14:41 | |
| * To change this template use File | Settings | File Templates. | |
| */ |
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
| public class NumberUnderscore { | |
| public static void main(String[] args) { | |
| int a; | |
| a = 222_222; | |
| a = 0b00_00; // binary literal | |
| a = 0_2; // octal | |
| // a = 0_9; illegal octal number | |
| // a = 3333._222; illegal | |
| // a = 2222_.222; illegal |
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
| import java.util.function.Function; | |
| public class CurryingExample { | |
| public static void main(String... args){ | |
| Function<String, Function<String, String>> concatStr = s -> s2 -> s + s2; | |
| System.out.println(concatStr.apply("Conca").apply("tenated")); | |
| } | |
| } |
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
| ;; γ«γͺγΌε | |
| (defn currize [[x & xs] body] | |
| `(fn [~x] | |
| ~(if xs | |
| (currize xs body) | |
| `(do ~@body)))) | |
| (defmacro currying [params & body] | |
| (currize params body)) |