views:

72

answers:

4

What are some ways of passing the return value of one function as an argument to another?

What are some examples in programming languages that you favor, JS, Python, etc?

A: 
var x = AnotherFunction(ReturnFunction(someVariable));

where AnotherFunction() accepts the same type that ReturnFunction() returns.

Most modern languages allow this.

JTA
+3  A: 

do you mean like the following C code:

int foo(void) {
    return 4; /* XKCD standard random number */
}

int bar(void) {
     do_something(2,foo());
     return 0;
}

That has nothing to do with functional programming [read up at http://en.wikipedia.org/wiki/Functional%5Fprogramming ]

Mikeage
A: 

In F# you can pipe it like so

 f() |> g

(assuming f returns a T and g takes a T)

Brian
A: 

In Haskell,

x . f . g 5
Clint Miller