i am reading Accelerated C# i don't really understand the following code:
public static Func<TArg1, TResult> Bind2nd<TArg1, TArg2, TResult> (
this Func<TArg1, TArg2, TResult> func,
TArg2 constant )
{
return (x) => func( x, constant );
}
in the last line what is x referring to? and there's another:
public static Func<TAr...
Jeffrey Meunier has an implicit Curry macro here, which uses defmacro. I was wondering if someone has ever written this with syntax-rules?
...
Still a Haskell newbie here. I know just enough to get myself into trouble with wrong assumptions. If I have the following function...
quadsum w x y z = w+x+y+z
I want a function that can take a list, use each element as a parameter in a specified function like quadsum, and return a curried function for later use.
I've been trying ...
Is there an elegant notation for Currying the arguments of a function out of order in Haskell?
For example, if you wish to divide 2 by all elements of a list, you can write
map ((/) 2) [1,2,3,4,5]
However to divide all elements of a list it seems you need to define an anonymous function
map (\x -> x/2) [1,2,3,4,5]
Anonymous functi...
So something like
addList :: [int] -> int
addList = foldl1 (+)
Why does this work? The Currying part. Why no variable?
Thanks
...
I have the following Scala class:
class Person(var name : String, var age : Int, var email : String)
I would like to use the Person constructor as a curried function:
def mkPerson = (n : String) => (a : Int) => (e : String) => new Person(n,a,e)
This works, but is there another way to accomplish this? This approach seems a bit tedio...
I am always interested in learning new languages, a fact that keeps me on my toes and makes me (I believe) a better programmer. My attempts at conquering Haskell come and go - twice so far - and I decided it was time to try again. 3rd time's the charm, right?
Nope. I re-read my old notes... and get disappointed :-(
The problem that mad...
First, let me show you the codez:
a = array([...])
for n in range(10000):
func_curry = functools.partial(func, y=n)
result = array(map(func_curry, a))
do_something_else(result)
...
What I'm doing here is trying to apply func to an array, changing every time the value of the func's second parameter. This is SLOOOOW (cre...