Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

composition in rust haskell and scheme

Name: Anonymous 2015-07-17 12:43

Rust:
// This function accepts any two functions and composes them into a single function accepting the
// input type for the first function and returning the output type of the second function.
fn compose<'f, T1, T2, T3, F1, F2>(a: F1, b: F2) -> Box<Fn(T1) -> T3 + 'f>
where F1: Fn(T1) -> T2 + 'f,
F2: Fn(T2) -> T3 + 'f
{
box move |input| b(a(input))
}


Haskell:
compose f g x = f (g x)

Scheme:
(define (compose f g)
(lambda (x)
(f (g x))))

Name: Anonymous 2015-07-17 14:51

Rust is the only choice in these, since it's the only one that don't have GC.

GC is shit.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List