jerome
jerome

Reputation: 4977

Passing return value of a function as an argument

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?

Upvotes: 0

Views: 215

Answers (4)

Clint Miller
Clint Miller

Reputation: 15381

In Haskell,

x . f . g 5

Upvotes: 0

Brian
Brian

Reputation: 118865

In F# you can pipe it like so

 f() |> g

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

Upvotes: 0

Mikeage
Mikeage

Reputation: 6564

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_programming ]

Upvotes: 3

Inisheer
Inisheer

Reputation: 20794

var x = AnotherFunction(ReturnFunction(someVariable));

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

Most modern languages allow this.

Upvotes: 0

Related Questions