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
(ns parsing) | |
;; http://www.cs.nott.ac.uk/~pszgmh/monparsing.pdf | |
(defn parse | |
[p input] | |
(p (seq input))) | |
(defn result | |
[v] |
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
Book | Author | |
---------------------------------------- | |
The Martian | Andy Weir | |
1984 | George Orwell | |
Starship Troopers | Robert A. Heinlein | |
The Gods Themselves | Isaac Asimov | |
Dune | Frank Herbert |
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 java.net.URI; | |
import java.nio.file.Files; | |
import java.nio.file.Paths; | |
public class Main { | |
public static void main(String[] args) throws Exception { | |
System.out.println(new String(Files.readAllBytes(Paths.get("/foo.txt")), "UTF-8")); | |
} | |
} |
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
user> (defn foo [& {:keys [bar] :or {bar 1}}] bar) | |
#'user/foo | |
user> (foo) | |
1 | |
user> (foo :baz 2) | |
1 | |
user> (foo :bar 2) | |
2 |
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 foo = bar = 42; | |
{ | |
"type": "Program", | |
"body": [ | |
{ | |
"type": "VariableDeclaration", | |
"declarations": [ | |
{ | |
"type": "VariableDeclarator", | |
"id": { |
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
;; javascripty | |
(var foo 42) | |
(var inc (function (x) (+ x 1))) | |
(function dec (x) (- x 1)) | |
;; clojurey | |
(def foo 42) | |
(def inc (fn [x] (x + 1))) | |
(defn dec [x] (- x 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
(defmacro apply (f arr) | |
`(f ~@arr)) | |
(apply str ["foo" "bar" "baz"]) | |
;; macroexpands to: | |
(str "foo" "bar" "baz") |
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
; Missionaries and Cannibals | |
;------------------------------------------------------------------------------- | |
; main method | |
( defmethod mc () | |
( establish-operators ) | |
( setup ) | |
( solve ) | |
) |
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
#include <string.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define BUFFER_SIZE 5 | |
struct reqdata | |
{ | |
char *data; | |
size_t len; |
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
#include <stdio.h> | |
#include <errno.h> | |
int main(int argc, char **argv) | |
{ | |
if (argc == 1) return 0; | |
if (argc == 2) { | |
char *filename = argv[1]; | |
FILE *fp = fopen(filename, "r"); | |
if (!fp) { |