Skip to main content
Filter by
Sorted by
Tagged with
4 votes
1 answer
120 views

I'm learning about Haskell and came across this concise, but weird, definition for a function that multiplies three numbers: volume :: Float -> Float -> Float -> Float volume = ((*) .) . (*) ...
zahiko's user avatar
  • 83
1 vote
1 answer
73 views

I need to write a function to add a particular command/string of characters to an existing function. Consider this function: constraint = function(cov_matrix,max_variance){ function(x){ f = NULL g =...
SuperLeo's user avatar
  • 135
1 vote
0 answers
64 views

I am expecting achieve function composition. The output for laplace defined as composition is different to symmetric This is my tried. from sympy import Function, Symbol from sympy.printing import ...
Oromion's user avatar
  • 129
3 votes
2 answers
268 views

When writing a program, I often want to perform a series of steps on a piece of data (usually a list or string). For example I might want to call a function which returns a string, convert it to a ...
David Moneysmith's user avatar
1 vote
1 answer
103 views

I was doing a past paper and was very confused by this question: enter image description here I tried to research about it, look at threads, watch youtube videos but I still do not understand it and ...
stevenoakman's user avatar
1 vote
1 answer
74 views

I have trouble with building composition function, using an array as an argument. Got this error TypeError: arr.map is not a function const testArray = ["CusTom", "Web", "...
Volodymyr Berkych's user avatar
1 vote
1 answer
165 views

I have 2 composing functions: compose and composeR. They receive 2 functions and compose them together in a way that, output of one function is passed as an input to another function. This is their ...
Shnd's user avatar
  • 2,090
2 votes
2 answers
257 views

I know that the dot (.) operator is defined to take three arguments(two functions and a value of type "a"), and works by the application of applying the argument to the function on the right,...
Akari's user avatar
  • 155
0 votes
2 answers
272 views

I'm playing with functional programming in C++20 and write something like that: template <class OuterFn, class InnerFn, class... Args> concept Composable = std::invocable<OuterFn, std::...
hlebyshek's user avatar
7 votes
3 answers
1k views

Python's standard library is vast, and my intuition tells that there must be a way in it to accomplish this, but I just can't figure it out. This is purely for curiosity and learning purposes: I have ...
ruohola's user avatar
  • 24.8k
1 vote
1 answer
5k views

I have a nested TypeScript type created with function composition. export const billingLoader = asyncPipe( withOrganizationMembership, withTFunction, withPageTitle({ tKey: 'billing:billing' }), ...
J. Hesters's user avatar
0 votes
0 answers
76 views

So I wanted to practice composing functions in C++, I have two functions f and g and composition is defined by x ↦ f(g(x)), I implemented the functions with specific data type (int) and it worked and ...
Peter's user avatar
  • 21
0 votes
1 answer
115 views

Java has java.util.function.Function.identity(T) which return a function equivalent to the lambda expression t -> t (and in fact that is the precise implementation on OpenJDK 17, which I'm looking ...
Garret Wilson's user avatar
1 vote
1 answer
56 views

While developing my programming skills, I often run into information along the lines of "Don't chain these functions together. Instead, use the built-in function that does both much faster."...
Zaz's user avatar
  • 49.1k
2 votes
2 answers
320 views

Take a super-simple struct Foo: #[derive(Debug)] struct Foo { a: i32 } and a compose macro I got here: macro_rules! compose { ( $last:expr ) => { $last }; ( $head:expr, $($tail:expr), +...
Jared Smith's user avatar
  • 22.3k
0 votes
1 answer
99 views

I'm practicing memoization to improve recursive functions, so I wrote this memoized Fibonacci generator: memo = {} def memo_fibo(n): if n not in memo: if n < 2: memo[n] = n ...
Imaginary's user avatar
  • 135
0 votes
1 answer
53 views

While doing exercises of chapter 3 of the Purescript by Example book was puzzled by this: The exercise is to write an isInBook :: String -> String -> AddressBook -> Boolean findEntryByName :: ...
Chris Wesseling's user avatar
3 votes
1 answer
324 views

TLDR: Is there a Haskell library that offers function definitions (preferably with concise notation or naming) for handling common patterns of multi-argument function composition such as those in APL? ...
j_v_wow_d's user avatar
  • 521
1 vote
1 answer
86 views

I have learned that point-free style is preferred in the Haskell community, and I often write expressions like this: naive = (slugifyUnicode . T.take maxFilenameSize . T.pack . stripHtmlTags . T....
Brendan Langfield's user avatar
0 votes
1 answer
55 views

function composition of single argument functions is a simple 1 liner. how would I (if it's possible) write the following composition in 1 line? def fn(x: int) -> str: def inner(a, b): ...
tex's user avatar
  • 21
3 votes
3 answers
1k views

I have a pure function that takes 18 arguments process them and returns an answer. Inside this function I call many other pure functions and those functions call other pure functions within them as ...
Joseph S's user avatar
  • 330
2 votes
1 answer
3k views

I'm working through question 11 on bfe.dev's JavaScript coding exercises. The question asks to chain multiple basic math functions together via composition. Here's some sample code that passes the ...
1sentenced's user avatar
0 votes
1 answer
1k views

Similar to this question Composing a Java Function and Consumer. What is the best way to functionally compose a java BiFunction and a Consumer? For example given some BiFunction<String, String,...
bootstrap2025's user avatar
2 votes
1 answer
1k views

If I have two functions f and g, in Haskell I can compose them by writing g.f. How do I do the same thing in Lean 4?
eyelash's user avatar
  • 4,126
0 votes
1 answer
152 views

I'm a huge fan of functional programming. I strive to use point free notation when I can. However, I often don't understand when point free notation is appropriate or when it is overkill. I typical ...
devinm's user avatar
  • 865
-2 votes
3 answers
297 views

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 ...
cvb0rg's user avatar
  • 73
3 votes
1 answer
537 views

I've read How to compose functions in Rust? Function composition chain in Rust I've learned implementing a Function composition chain in Rust is rather difficult, and people use Macro with some ...
SmoothTraderKen's user avatar
0 votes
1 answer
207 views

In dart, with generics, the identity function works as below: a to a: var id = <A>(A a) => a; a to the list type [a]: var list = <A>(A a) => [a]; Now, I have function composition ...
SmoothTraderKen's user avatar
23 votes
3 answers
16k views

I would like to figure out what are the advantages of using Pinia store instead of using just pure ts composable functions like const userName = ref('') export default function useUser() { const ...
Petr Klein's user avatar
  • 1,053
1 vote
1 answer
1k views

I want to implement function composition in an object method chain in Rust. Before that, I confirmed that implementation of an object method chain for "pipe" of function application is ...
SmoothTraderKen's user avatar
1 vote
0 answers
192 views

I encountered this in my own library, so I thought I would check against the Redux compose function that does the same thing. I found the same issue. Because redux is considerably more popular than my ...
spender's user avatar
  • 121k
2 votes
6 answers
235 views

I'm working on an NES emulator in c++ and figured that the most efficient way to run opcodes would be to call a function pointer in an array of functions that do exactly what the opcode does. The ...
MrFlapjack's user avatar
1 vote
1 answer
52 views

I am digging into math currently and tried to build a simple function composition maker https://en.wikipedia.org/wiki/Function_composition I want to tell the program: Look at two tuples and compare ...
fbn001's user avatar
  • 31
2 votes
2 answers
1k views

I am trying to implement a kind of simple processing pipeline in Go, where each processor has a determined input and output type, and a list of successor processors that take current processor output ...
woooosh's user avatar
  • 31
2 votes
1 answer
355 views

I have encountered a problem with some code I am trying to write in Idris 2. I would like to resolve this issue, but more importantly, I wish to understand it more deeply and develop some skills in ...
label17's user avatar
  • 173
2 votes
4 answers
1k views

Below are three functions that need to be composed and give us the output 30: const add = (a) => a + 10; const mul = (a) => a * 10; const divide = (a) => a / 5; // How to implement `...
Sandipan Bhattacharjee's user avatar
3 votes
1 answer
335 views

The Function interface has the compose() and andThen() methods while the BiFunction interface only has the andThen() method. My question is simply how could the corresponding method be implemented? I'...
PianoMastR64's user avatar
1 vote
2 answers
207 views

I have some trouble understanding this example: data Row = R [Int] deriving Show data Matrix = M [Row] deriving Show check :: Matrix -> Int -> Bool check (M matrix) n = foldr ((&&...
Johnny's user avatar
  • 447
3 votes
2 answers
347 views

I'm trying to make a statically type-checked "decorators" for functions. Basically, it is a helper for function composition from the right to remove the nesting. The issue is that while ...
spyke's user avatar
  • 385
2 votes
1 answer
224 views

This is an exercise: -- Ex 12: recall the binary function composition operation -- (f . g) x = f (g x). In this exercise, your task is to define a function -- that takes any number of functions given ...
lt512's user avatar
  • 313
1 vote
1 answer
609 views

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 ...
user avatar
1 vote
0 answers
239 views

Related to my previous question: Type inference of Function composition method (chain) in TypeScript I try to implement a function that is to extend a specified function to have a chainable method for ...
Functor's user avatar
  • 610
1 vote
1 answer
343 views

I try to implement a function that is to extend a specified function to have a chainable method for function composition; as below; Also see: TypeScript playground { const F = <T, U>(f: (a: T) ...
Functor's user avatar
  • 610
16 votes
4 answers
894 views

I'm studying functional composition and have an example: Function<String, String> test = (s) -> s.concat("foo"); String str = test.andThen(String::toUpperCase).apply("bar")...
Sharper's user avatar
  • 173
3 votes
2 answers
256 views

I'm learning haskell, and I'm trying to rewrite a function using composition only Here's the function I'm trying to refactor: ceilingDiv a b = ceiling (a / b) So far I managed to make it work using ...
Isthos's user avatar
  • 33
3 votes
1 answer
166 views

I have two curried functions f and g: f: a -> b -> c g: a -> c -> d I want to create h: h: a -> b -> d Currently I'm composing them via pipe: const h = a => pipe(f(a), g(a)); ...
J. Hesters's user avatar
1 vote
3 answers
104 views

Say, we want to introduce the notion of sum of functions of different arguments (let's call it <+>), which behaves like the that: (f1 <+> f2)(x1, x2) == f1(x1) + f2(x2). While this can be ...
heinwol's user avatar
  • 448
1 vote
1 answer
727 views

I am following some video presentation on Kotlin's arrow library about functional programming. I have come to this example of function composition: val greaterThanThree = { it > 3 } val even = { ...
Leff's user avatar
  • 1,610
0 votes
2 answers
165 views

I am trying to make composition using generators. function A(x){return 1+x} function B(y){return 2*y} let val=tryCompose([A,B](1); //output should be : A(B(1)) How should the generator function ...
user8599269's user avatar
0 votes
3 answers
291 views

I am working on C implementations of calculus operations (such as derivatives, integrals, etc...). As an example, here's the template definition of my derivative function: double derivative(double (*f)...
Skander J.'s user avatar

1
2 3 4 5
9