currying

F# curried function

Anyone have a decent example, preferably practical/useful, they could post demonstrating the concept? ...

Javascript curry - what are the practical applications?

I don't think I've grokked currying yet. I understand what it does, and how to do it. I just can't think of a situation I would use it. Where are you using currying in javascript (or where are the main libraries using it)? DOM manipulation or general application development examples welcome. EDIT: One of the answers mentions animation....

How can currying be done in C++?

What is currying? How currying can be done in c++? Please Explain binders in STL container? ...

What is the difference between currying and partial application.

I'm not exactly sure how to word this question. I learnt what currying was in the first year of university, and have been using it where applicable ever since. However, 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 foun...

Implementation of Curried Functions in Scheme

What happens when I do the following? (define ((func x) y) (if (zero? y) ((func x) 1) 12)) I understand that I can do this: (define curried (func 5)) And now I can use curried. What I'm curious about is in the definition of the function. Does the line ((func x) 1) create a new lambda with x as the argument, a...

What is the differences and possible similarities of closures and currying?

I've read through some of the post on here about closures and currying but I feel like I didn't find the answer. So what's the differences and possibly the similarities of closures and currying? Thanks for the help :) ...

Proper Currying in C#

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? public static TResult DoSomething<TResult>(Func<TResult> func) { //call func() and do something else } public static TResult DoSomething<T...

Why can't I implicitly cast a Delegate with Extension methods?

I'm trying to figure out a way to automatically cast something to an Action or Func and the best I can come up with is something like this: [TestFixture] public class ExecutionTest { public void BadMethod() { throw new Exception("Something bad happened"); } [Test] public void TestBadMethod() { //...

Beginner: Curried functions in Scheme

I'm using the SICP lectures and text to learn about Scheme on my own. I am looking at an exercise that says "An application of an expression E is an expression of the form (E E1,...En). This includes the case n=0, corresponding to an expression (E). A Curried application of E is either an application of E or an application of a Curried ...

Semantics of F# statement

Can someone describe this F# expression to me? val augment: GameGrid -> points -> unit What does the val keyword mean? Is it true that usually type -> type indicates a function that returns the specified type? So does type -> type -> type indicate a function that returns a function that returns the specified type? ...

Confusion about currying and point free style in Haskell

I was trying to implement the function every :: (a -> IO Bool) -> [a] -> IO Bool which was the topic for this question. I tried to do this without explicit recursion. I came up with the following code every f xs = liftM (all id) $ sequence $ map f xs My function didn't work since it wasn't lazy (which was required in the question),...

F#: curried overload/tupled overload issue

While migrating some code to the latest version of F#, included in VS2010 b1, I've encountered an issue and I'd like to know if there's a workaround available and - if not - why was the behavior of the F# compiler modified not to support the scenario. type Foo(a) = [<OverloadID("CurriedAbc")>] member public x.Abc (p:(oneType * ...

Is there a way to do currying in C?

Say I have a pointer to a function _stack_push(stack* stk, void* el). I want to be able to call curry(_stack_push, my_stack) and get back a function that just takes void* el. I couldn't think of a way to do it, since C doesn't allow runtime function definition, but I know there are far cleverer people than me here :). Any ideas? ...

Doing a N-dimensional walk in pure functional ML ?

The idea is to walk over multiple dimensions, each one defined as a range (* lower_bound, upper_bound, number_of_steps *) type range = real * real * int so functions like fun foo y x or fun foo z y x could be applied to the whole square X*Y or cube X*Y*Z. SML/NJ doesn't like my implementation below : test2.sml:7.5-22.6 Error: right-...

"Uncurrying" an instance method in .NET

EDIT: Highlight difficulties with virtual and/or value-type methods Can you create a delegate of an instance method without specifying the instance at creation time? In other words, can you create a "static" delegate that takes as it's first parameter the instance the method should be called on? For example, how can I construct the fo...

Functional programming: currying

Writing as an unreconstructed imperative & OO programmer... Have messed about with Erlang and also Haskell lately. I like Erlang, not sure yet about Haskell. Functional seems more like math than programming, hope that makes sense. Functional programming seems very powerful. Reading docs on the interwibble wrt functional programming I c...

Using Curry to Define Grails Tags

I have a grails tag library TpTagLib and in it I want to define 4 new tags that differ only in one constant value, so I tried to use curry. But there is an exception: groovy.lang.MissingPropertyException: No such property: attr for class: TpTagLib Does anyone have any idea why this exception occurs? Here is the code: def ifPermsTag = ...

Is there a way to get a Curried form of the binary operators in SML/NJ?

For example, instead of - op =; val it = fn : ''a * ''a -> bool I would rather have - op =; val it = fn : ''a -> ''a -> bool for use in val x = getX() val l = getList() val l' = if List.exists ((op =) x) l then l else x::l Obviously I can do this on my own, for example, val l' = if List.exists (fn y => x = y) l then l else x::l...

How to curry a function in Scala

I'm trying to call a 2 parameters function in List.foreach, with the first parameter fixed for a loop. In fact I want to curry a function of two parameters into a function of one parameter which returns a function of one parameter (as List.foldLeft do) This does not work: private def mathFunc1(a: Double, b: Double) = println(a + b)...

Is it possible to curry method calls in PHP?

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 calls so that I can omit the username and password? ...