Created
July 7, 2018 19:25
-
-
Save dc-mak/9bf8070a471c9a52e79a31ecd1dadede to your computer and use it in GitHub Desktop.
Higher Order Functions (Solving Problems in Computer Science, ATypical CompSci)
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 id = x => x; | |
let just = (y, _) => y; | |
let (+) = (f, g, x) => f(x) +. g(x); | |
let (-) = (f, g, x) => f(x) -. g(x); | |
let ( * ) = (f, g, x) => f(x) *. g(x); | |
let (@) = (f, g, x) => f(g(x)); | |
let sq = id * id; | |
let f = id + sin * (cos @ sq) - just(3.); | |
/* Outside Inwards */ | |
/* let f = ((f,g) => (x) => f(x) +. g(x))(sin, cos @ sq - just(3.)); */ | |
let f = ((f, g, x) => f(x) +. g(x))(id, sin * cos @ sq - just(3.)); | |
let f = x => id(x) +. (sin * cos @ sq - just(3.))(x); | |
let f = x => x +. (sin * cos @ sq - just(3.))(x); | |
/* let f = x => x +. ((f, g) => (x) => f(x) *. g(x))(sin, cos @ sq - just(3.))(x); */ | |
let f = x => | |
x +. ((f, g, x) => f(x) *. g(x))(sin, cos @ sq - just(3.), x); | |
let f = x => x +. sin(x) *. (cos @ sq - just(3.))(x); | |
/* let f = x => x +. sin(x) *. ((f, g) => (x) => f(x) -. g(x))(cos @ sq, just(3.))(x); */ | |
let f = x => | |
x +. sin(x) *. ((f, g, x) => f(x) -. g(x))(cos @ sq, just(3.), x); | |
/* let f = x => x +. sin(x) *. (cos @ sq)(x) -. just(3.)(x); */ | |
let f = x => x +. sin(x) *. (cos @ sq)(x) -. just(3., x); | |
let f = x => x +. sin(x) *. (cos @ sq)(x) -. 3.; | |
/* let f = x => x +. sin(x) *. ((f, g) => (x) => f(g(x)))(cos, sq)(x) -. 3.; */ | |
let f = x => x +. sin(x) *. ((f, g, x) => f(g(x)))(cos, sq, x) -. 3.; | |
let f = x => x +. sin(x) *. cos(sq(x)) -. 3.; | |
let f = x => x +. sin(x) *. cos((id * id)(x)) -. 3.; | |
/* let f = x => x +. sin(x) *. cos(((f,g,x) => f(x) *. g(x))(id, id)(x)) -. 3.; */ | |
let f = x => | |
x +. sin(x) *. cos(((f, g, x) => f(x) *. g(x))(id, id, x)) -. 3.; | |
let f = x => x +. sin(x) *. cos(id(x) *. id(x)) -. 3.; | |
let f = x => x +. sin(x) *. cos(x *. x) -. 3.; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment