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
>>> from rx import Observable | |
>>> help(Observable.flat_map_latest) |
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
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ | |
/* */ | |
/* Simple node js module to get distance between two coordinates. */ | |
/* */ | |
/* Code transformed from Chris Veness example code - please refer to his website for licensing */ | |
/* questions. */ | |
/* */ | |
/* */ | |
/* Latitude/longitude spherical geodesy formulae & scripts (c) Chris Veness 2002-2011 */ | |
/* - www.movable-type.co.uk/scripts/latlong.html */ |
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
empty_list = None | |
def prepend(el, lst): | |
def func(selector): | |
return selector(el, lst) | |
return func | |
def head(lst): | |
def selector(h, t): | |
return h |
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
actions=[] | |
for x in range(10): | |
actions.append(lambda: print(x)) | |
for act in actions: | |
act() |
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
// A (synchronous) function that might block forever | |
let later () = | |
System.Console.ReadLine() |
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
// Callback handler | |
let myCallback x = | |
printfn "Got %A" x | |
// Asynchronous function taking a callback handler | |
let asyncFun x cb = | |
let result = x * 10 | |
cb result | |
// Call function with provided callback handler |
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 add a b = a + b | |
let square x = x * x | |
let pythagoras a b = sqrt (add (square a) (square b)) | |
let result = pythagoras 10.0 20.0 |
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 addCps a b cont : unit = | |
cont (a + b) | |
let squareCps x cont : unit = | |
cont (x * x) | |
let sqrtCps x cont : unit = | |
cont (sqrt x) | |
// Pythagoras rewritten in CPS |
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
// Return a function that takes a callback that takes the result. | |
let times10 (x: int) : ((int -> unit) -> unit) = | |
let thenDo (cb : int -> unit) = | |
cb (x * 10) | |
thenDo | |
let cb result = | |
printfn "%A" result | |
let thenDo = times10 42 |
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
// An asynchronous value | |
let valAsync = async { return 42 } |
OlderNewer