$ brew install autoconf automake gmp homebrew/versions/bison27 gd freetype t1lib gettext zlib mcrypt
$ git clone --depth=1 https://github.com/php/php-src.git
$ cd php-src
DROP FUNCTION IF EXISTS lowerword; | |
DELIMITER | | |
CREATE FUNCTION lowerword( str VARCHAR(128), word VARCHAR(5) ) | |
RETURNS VARCHAR(128) | |
DETERMINISTIC | |
BEGIN | |
DECLARE i INT DEFAULT 1; | |
DECLARE loc INT; | |
SET loc = LOCATE(CONCAT(word,' '), str, 2); |
public class Solution { | |
public void traverse(TreeNode root) { | |
Queue<TreeNode> nodes = new ArrayList(); | |
nodes.add(root); | |
while (!nodes.isEmpty()) { | |
TreeNode node = nodes.remove(); | |
System.out.println(node.val); | |
if (node.left != null) queue.add(node.left); |
const cons = (x, y) => (m) => m(x, y); | |
const car = (z) => z((p, q) => p); | |
const cdr = (z) => z((p, q) => q); | |
const pair = cons(1, 2); | |
console.log(car(pair), cdr(pair));//1 2 | |
const list = cons(1, cons(2, cons(3, cons(4, null)))); | |
const each = (l, fn) => cdr(l) ? (() => {fn(car(l)); each(cdr(l), fn)})() : fn(car(l)); | |
each(list, console.log);//1 2 3 4 |
(defn make-acumulator [value] | |
(def acc (atom value)) | |
(fn [add] | |
(swap! acc #(+ % add)) | |
@acc)) | |
(def a (make-acumulator 10)) | |
(a 10) | |
;20 |
(define (create-user name) | |
(define say-hello | |
(print "Hello " name)) | |
(define (change-name new-name) | |
(set! name new-name) | |
name) | |
(define (dispatch method) | |
(cond | |
((eq? method 'say-hello) say-hello) | |
((eq? method 'change-name) change-name) |
; Let lambda syntactic sugar | |
(let [var1 exp1 | |
var2 exp2] | |
(do-something var1 var2)) | |
((fn [var1 var2] | |
(do-something var1 var2)) | |
(exp1 exp2)) |
; LINEAR RECURSION | |
(define (factorial n) | |
(if (= n 1) | |
1 | |
(* n (factorial (- n 1))))) | |
(factorial 3) | |
;(* 3 (factorial 2)) | |
;(* 3 (* 2 (factorial 1))) | |
;(* 3 (* 2 1)) |
<?php | |
class StreamHttpClient implements HttpClient | |
{ | |
public function request($url, $method, array $parameters = []) | |
{ | |
$content = http_build_query($parameters); | |
$options = ['method' => $method]; |
(defn nilakantha [iterations] | |
(loop [sum 3.0M | |
counter 0 | |
sign +] | |
(if (>= counter (* 2 iterations)) | |
sum | |
(recur | |
(sign sum | |
(/ 4.0M | |
(* (+ counter 2) |