currying Questions
5
Solved
I have this curry function:
(define curry
(lambda (f) (lambda (a) (lambda (b) (f a b)))))
I think it's like (define curry (f a b)).
my assignment is to write a function consElem2All using curry...
9
Solved
I have a SoapClient instance generated for a WSDL file. All except one of the method invocations require the username and the password to be passed id.
Is there any way of currying the method call...
2
Solved
I attempt to implement a currying function similar to Functional Programming Jargon in Rust:
fn add_origin(x: i32) -> impl Fn(i32) -> i32 {
return move |y| {
x + y
};
}
fn main() {
let a...
Scot asked 22/9, 2020 at 7:31
4
Solved
Given a method DoSomething that takes a (parameterless) function and handles it in some way. Is there a better way to create the "overloads" for functions with parameters than the snippet below?
p...
10
Solved
I am trying to write a currying decorator in python. I got this far:
def curry(fun):
cache = []
numargs = fun.func_code.co_argcount
def new_fun(*args, **kwargs):
print(args)
print(kwargs)
...
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...
Bridwell asked 11/3, 2013 at 5:23
7
Solved
In Python, I'd like to write a function make_cylinder_volume(r) which returns another function. That returned function should be callable with a parameter h, and return the volume of a cylinder wit...
Heffner asked 10/1, 2013 at 15:34
3
Solved
This is more of a conceptual question. I'm trying to find the easiest way of converting a two-arg template (the arguments being types) into a one-arg template. I.e., binding one of the types.
This...
Setiform asked 25/11, 2014 at 10:45
1
Solved
I'm trying to create a callable variable for a class method.
class Person {
method walk(Str $direction) {
say "Walking $direction";
}
}
I can create a callable variable for the method...
4
Solved
As per manual, functools partial() is 'used for partial function application which “freezes” some portion of a function’s arguments and/or keywords resulting in a new object with a simplified signa...
25
Solved
I've seen references to curried functions in several articles and blogs but I can't find a good explanation (or at least one that makes sense!)
Gerda asked 30/8, 2008 at 20:12
6
Solved
Let's say I have some function:
function g(a,b,c){ return a + b + c }
And I'd like to turn it into its "curried" form (in quotations since it's not exactly curried per se):
function h(a,b,c){
...
Coda asked 27/9, 2013 at 3:27
12
Solved
What is currying?
How can currying be done in C++?
Please Explain binders in STL container?
Moke asked 30/9, 2008 at 6:51
3
Solved
I have a method with 4 parameters that gets used in blocks. Within each block, the first parameter is always the same:
// Block 1 - first parameter always "A"
foo(a="A", b="x", c="y", d="z")
foo(a...
Fluorinate asked 21/1, 2016 at 11:26
5
Solved
While going through Functional Programming in Scala, I came across this question:
Can you right foldLeft in terms of foldRight? How about the other way
around?
In solution provided by the aut...
Alcyone asked 16/6, 2013 at 19:14
1
Solved
Trying to grasp Scala 3 type system.
Question:
Is it possible to write a single universal def curry(f: ???) = ... function that accepts f of any arity and returns a curried fn? No compiler plugins...
Hypaesthesia asked 11/2, 2023 at 7:4
33
Solved
I want to make this syntax possible:
var a = add(2)(3); //5
based on what I read at http://dmitry.baranovskiy.com/post/31797647
I've got no clue how to make it possible.
Coign asked 16/2, 2010 at 12:44
3
Solved
Suppose we have a nested generic class:
public class A<T> {
public class B<U> { }
}
Here, typeof(A<int>.B<>) is in essence a generic class with two parameters where only...
5
Solved
TypeScript 3.0 introduced generic rest parameters.
Up until this point, curry functions had to be annotated in TypeScript with a finite number of function overloads and a series of conditional stat...
Denier asked 15/8, 2018 at 13:15
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
19
Solved
I need a js sum function to work like this:
sum(1)(2) = 3
sum(1)(2)(3) = 6
sum(1)(2)(3)(4) = 10
etc.
I heard it can't be done. But heard that if adding + in front of sum can be done.
Like +sum(...
Chaff asked 29/4, 2011 at 13:47
6
I'm very new to Haskell and FP in general. I've read many of the writings that describe what currying is, but I haven't found an explanation to how it actually works.
Here is a function: (+) :: a ...
3
If first parameter is taken by the function first as function application is left-associative, for example:
drop 2 [1,2,3,4]
result: [3,4]
is equivalent to
(drop 2) [1,2,3,4]
same result: [3,4]
H...
Scarron asked 5/5, 2022 at 9:33
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
7
Solved
Say I have a function called multiplyDivide
If I were to call multiplyDivide(2)(3)(4)(6) it would be equivalent to 2 * 3 / 4 * 6.
Update:
Is it possible to write a function like this if I don't k...
Kazbek asked 28/8, 2016 at 2:49
1 Next >
© 2022 - 2024 — McMap. All rights reserved.