partial-application Questions

2

Solved

From a function with multiple parameters can we partially apply just one or two parameters to it returning a new function that takes the remaining parameters? Javascript example using Ramda funct...
Younglove asked 22/11, 2018 at 16:4

9

Solved

I am not able to get my head on how the partial works in functools. I have the following code from here: >>> sum = lambda x, y : x + y >>> sum(1, 2) 3 >>> incr = lambda y...

8

Partial application is cool. What functionality does functools.partial offer that you can't get through lambdas? >>> sum = lambda x, y : x + y >>> sum(1, 2) 3 >>> incr =...
Kenny asked 15/7, 2010 at 3:16

4

Solved

Suppose I have a function in R that takes multiple arguments, and I'd like to reduce it to a function of fewer arguments by setting some of the arguments to pre-specified values. I'm trying to figu...
Orchestrate asked 24/8, 2015 at 3:1

1

I am wondering whether the following is possible in Scala: Given some vector x = (x_1, x_2, ..., x_n) in R^n and a function f that maps R^n to R, I would like to replicate this concept in Scala. Th...
Thalassography asked 23/1, 2023 at 21:58

13

Solved

Take for example the python built in pow() function. xs = [1,2,3,4,5,6,7,8] from functools import partial list(map(partial(pow,2),xs)) >>> [2, 4, 8, 16, 32, 128, 256] but how would I...
Slightly asked 23/6, 2012 at 22:58

3

Solved

The following SML code is taken from a homework assignment from a course at University of Washington. (Specifically it is part of the code provided so that students could use it to complete Homewor...
Unpleasant asked 13/8, 2022 at 5:50

3

Solved

Since Kotlin supports many concepts from functional programming, I was wondering if there is a way to do partial application of a function in Kotlin as well? One such example of where partial appl...
Mortie asked 9/10, 2018 at 0:6

16

Solved

I quite often see on the Internet various complaints that other peoples examples of currying are not currying, but are actually just partial application. I've not found a decent explanation of wha...
Extraterrestrial asked 20/10, 2008 at 10:41

17

I was wondering if there is any way to pull that in Java. I think it is not possible without native support for closures.
Charlean asked 26/5, 2011 at 5:54

1

Solved

Here's a 'compose' function which I need to improve: const compose = (fns) => (...args) => fns.reduceRight((args, fn) => [fn(...args)], args)[0]; Here's a practical implementation of one:...

11

Solved

How can I call Function.prototype.bind with an array of arguments, as opposed to hardcoded arguments? (Not using ECMA6, so no spread operator). I'm trying to put a promises wrapper around a module...

7

Solved

How can I bind arguments to a Python function so that I can call it later without arguments (or with fewer additional arguments)? For example: def add(x, y): return x + y add_5 = magic_function(a...
Southwick asked 10/11, 2008 at 14:1

1

Solved

I'm trying to understand something about Haskell functions. First, here is a Fibonacci function defined in the typical "slow" way (i.e. recursive with no memoization, and no infinite-list tricks) ...

4

Solved

Learning Haskell some time ago, I felt in love with pointfree notation and especially convenient partial function application - just supply args you know. In Clojure, I have partial all the time. I...
Relapse asked 6/9, 2013 at 1:6

2

Solved

I have a couple classes and a function: from functools import partial def fn(other, self, name): print(f"calling {name} with {other}") func = getattr(self.a, name) return func(other) c...
Fyrd asked 14/1, 2020 at 22:24

3

Solved

So I am trying to understand partial: import functools def f(x,y) : print x+y g0 = functools.partial( f, 3 ) g0(1) 4 # Works as expected In: g1 = functools.partial( f, y=3 ) g1(1) 4 # Wor...
Sallyanne asked 15/7, 2014 at 10:10

3

Solved

According to my understanding, partial functions are functions that we get by passing fewer parameters to a function than expected. For example, if this were directly valid in Python: >>>...

2

Solved

I am looking for a way to partially apply functions in python that is simple to understand, readable, resusable and as little error prone to coder mistakes as possible. Most of all I want the style...
Strumpet asked 6/9, 2019 at 13:20

2

Solved

I've created a list of partially applied functions in my REPL like so: listOfPartiallyAppliedFunctions = map (*) [1..100] I would then like to create the list of results from completing the func...

1

Solved

Consider the following type definition: trait LiftF[F[_], G[_]] { def liftF[A](fa: F[A]): G[A] } When providing a requirement for an implicit of this type in context bounds (using kind projecto...

4

Solved

For partial function application, I know there are several ways to do that in Python. However, they seems not to preserve the original function's docstring. Take functools.partial as example: fro...
Bullock asked 8/12, 2014 at 16:46

4

Solved

in F# if I take a function that takes two arguments, for example, mod (%): 13 % 10 // val it : int = 3 which is the same as (%) 13 10 // val it : int = 3 is there any way to write it in the ...
Servais asked 7/8, 2018 at 15:34

5

Solved

How is this possible, what is going on there? Is there a name for this? What other languages have this same behavior? Any without the strong typing system?

1

Solved

I've been looking into Functional Programming lately and wanting to bring some concepts to my C# world. I'm trying to compose functions to create services (or whatever you'd call them) instead of c...
Singleton asked 1/6, 2018 at 8:41

© 2022 - 2025 — McMap. All rights reserved.