Questions tagged [function-composition]

Applying one function to the result of another is known as function composition: `(f.g)(x) = f(g(x))`

Applying one function to the result of another is known as function composition: (f.g)(x) = f(g(x)).

See also .

420 questions
0
votes
1 answer

Take a list of functions and compose the list with a value

I'm currently attempting to do this problem from the ebook, Haskell School of Music: Define a function applyAll that, given a list of functions [ f1, f2, ..., fn ] and a value v, returns the result f1 (f2 (...(fn v)...)). For example: applyAll…
Meta
  • 15
  • 1
  • 5
0
votes
1 answer

Action Compositon Play2 Java

I'm currently developing a web service with Play2 and I have a problem with action composition. Here is one of the methods available for my web service : @Authenticated(Secured.class) @BodyParser.Of(BodyParser.Json.class) public static Result…
c4k
  • 4,270
  • 4
  • 40
  • 65
-1
votes
1 answer

Should I return the object itself just for function chain

I have been wondering whether should I return the object itself from a setter or procedure (returning void originally), so that all the function can chain together. We've all been taught to return void when there is nothing to return, but is…
user15459834
-1
votes
1 answer

TypeError: Object is not a function or its return value is not iterable, when i use useState (function component)

const [text, setText] = useSate('') const [day, setDay] = useSate('') const [remainder, setRemainder] = useSate(false)
Sava
  • 113
  • 1
  • 13
-1
votes
1 answer

Refactor `f(g(x))(x)` so that I can compose this nicely

I have a couple of functions that currently are written (in abstract form) like this... const someFunction = x => f(g(x))(x); i.e. pass x into g to get the output. Then pass that output into f to get a function. And then pass x into that…
Fogmeister
  • 76,236
  • 42
  • 207
  • 306
-1
votes
2 answers

Confusing function application and function composition in Haskell

The operation (filter (`notElem` "'\"").[(1,'a','%',"yes")]) gives an error. How can apply this filter on that list properly?
thetux4
  • 1,583
  • 10
  • 25
  • 38
-1
votes
1 answer

"foo" is "a -> b -> c". "foo . foo" is also "a -> b -> c". Does Haskell treat them exactly the same in terms of speed?

foo :: a -> b -> c foo = undefined ghci> :t foo foo :: a -> b -> c ghci> :t foo . foo foo . foo :: a -> b -> c ghci> :t foo . foo . foo foo . foo . foo :: a -> b -> c And so on. The types are the same. We also clearly see, just by looking at the…
haskellHQ
  • 1,027
  • 6
  • 15
-1
votes
2 answers

Composition of "pow" functions in C

I am trying to integrate a couple of equations, but the program fails to compile. The error message that appears says: "too many arguments to function pow" I will show the problematic part of the code and then make two specific questions. #include…
-2
votes
3 answers

Function composition with just lambdas in python

Is there a way to do the following in just one line with lambdas in python? squared = lambda x : x**2 cubed = lambda x : x**3 squareCubed = lambda x : squared(cubed(x)) without using any helper functions or reduce. print(squareCubed(2)) # > 64
cvb0rg
  • 73
  • 6
-2
votes
1 answer

why is juxt named after juxtaposition?

Why is Clojure's juxt named after juxtaposition? I don't see what is being juxtaposed. This is in contrast to partial and comp which have intuitive naming.
m33lky
  • 7,055
  • 9
  • 41
  • 48
-2
votes
2 answers

Can this expression be written without brackets or back-ticks?

mul (add 2 3) 5 Can the dot (.) and dollar ($) operators alone replace the brackets? The mul and add functions are filler, i.e. the order of application must stay the same. This is an exercise to better understand the aforementioned operators.
Ware
  • 97
  • 6
-2
votes
2 answers

Javascript: Compose a function with argument placement instructions for each composition

I'm looking for a javascript function that can: Condition (I) compose another function when it does not have recursion in its definition, kind of like in maths when the function is given a power, but with multiple arguments possible in the first…
Sophiα2329
  • 1,601
  • 1
  • 13
  • 15
-2
votes
3 answers

Composite Functions in C

If i have a composition of functions f(f(f(f(x)))) how can i write it as function in C ? Is it possible to write it with recursive algorithm? For example what happens if we have the following function: f(x)=cosa*X1+cosb*X2 where x=(X1,X2)
Otinane
  • 29
  • 9
-3
votes
1 answer

haskell Chess Knight Tour: Function composition

I've a hard time understanding a Chess Knight problem concerning function composition. The exercise is a generator/filter/selector chain with a given wrapper function (knightProblem) which glues everything together. It is unclear to me how the…
-6
votes
1 answer

Composing applicative functions

Please implement the function: composeApplicative :: (Applicative f) => f (b -> c) -> f (a -> b) -> f (a -> c) Such that: (composeApplicative f g) <*> x == f <*> (g <*> x) Or alternatively, explain why this can not be done?
Clinton
  • 22,361
  • 15
  • 67
  • 163
1 2 3
27
28