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
Guess | Quotient | Average | |
---|---|---|---|
1 | 2/1 = 2 | (2 + 1)/2 = 1.5 | |
1.5 | 2/1.5 = 1.3333 | 1.3333 + 1.5/2 = 1.4167 | |
1.4167 | 2/1.4167 = 1.4118 | (1.4167 + 1.4118)/2 = 1.4142 | |
1.4142 | ... | ... |
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
module State = struct | |
type t = int | |
let inc (n: t) = Transformer.inc n | |
end | |
;; | |
module Transformer = struct | |
let inc (n: State.t) = n + 1 | |
end | |
;; |
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
// Register firebase module | |
var app = angular.module("app", ["firebase"]); | |
// Set up controller function | |
app.controller("Ctrl", function($scope, $firebase) { | |
var firebaseRef = new Firebase( | |
// Replace this fictional URL with your own | |
"https://burning-limbo-6666.firebaseio.com/colors" | |
); | |
// create an AngularFire ref to the data |
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
let transpose A = | |
let new_mat = Array.make_matrix (Array.length A.(0)) (Array.length A) 0 | |
in | |
for y = 0 to (Array.length A) - 1 do | |
for x = 0 to (Array.length A) - 1 do | |
new_mat.(y).(x) <- A.(x).(y) | |
done | |
done; | |
new_mat | |
in |
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
type 'a tree = | |
| Leaf | |
| Node of 'a * 'a tree * 'a tree | |
let node_of_tx tx = if String.length tx > 0 then Node (tx, Leaf, Leaf) else Leaf | |
let tree_of_txs txs = | |
let nodes = List.map node_of_tx txs in | |
match nodes with | |
| [] -> Leaf |
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
type socket | |
type event | |
type config = { | |
reconnect: bool; | |
debug: bool; | |
timeout: int; | |
interval: int | |
} |
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
package main | |
import ( | |
"log" | |
"strings" | |
) | |
type Session struct { | |
Email string | |
Password string |
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 search(dst, arr) { | |
// sort the input array | |
arr.sort((a, b) => a-b); | |
// if array is reduced to a member and still no match, return false | |
if ((arr.length == 1) && (arr[0] !== dst)) | |
return false; | |
// define a middlebound |
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
package main | |
import "fmt" | |
type List struct { | |
Inner []int | |
} | |
func NewList(s []int) List { | |
return List{Inner: s} |