Re: A currying function

2012-06-21 Thread Philippe Sigaud
On Fri, Jun 22, 2012 at 12:12 AM, Artur Skawina wrote: > Sure, but partial application would be enough for cases like this one. > > I wonder if there's a case for "real" currying in 'D'; still can't think > of one, but maybe that's just because it's not how i would usually code it. Ah yes, you'r

Re: A currying function

2012-06-21 Thread Artur Skawina
On 06/21/12 21:04, Philippe Sigaud wrote: > On Tue, Jun 19, 2012 at 2:52 PM, Artur Skawina wrote: > >> I'm not really sure when you'd want to use this in D. > > As for Haskell. For example, with a range of ranges and you want to > take the first 100 elements of all subranges: > > alias Curry!ta

Re: A currying function

2012-06-21 Thread David Nadlinger
On Thursday, 21 June 2012 at 19:04:32 UTC, Philippe Sigaud wrote: As for Haskell. For example, with a range of ranges and you want to take the first 100 elements of all subranges: alias Curry!take ctake; auto target = [[0,1,2,...], [...], ]; auto first100s = map!(ctake(100))(target); To me,

Re: A currying function

2012-06-21 Thread David Nadlinger
On Thursday, 21 June 2012 at 19:04:32 UTC, Philippe Sigaud wrote: On Tue, Jun 19, 2012 at 2:52 PM, Artur Skawina But, just to be able to say "Real Programmers don't use mixins": :) I find Bearophile version quite nice. I did something equivalent a few years ago, with string mixins also. […]

Re: A currying function

2012-06-21 Thread bearophile
Philippe Sigaud: alias Curry!take ctake; auto target = [[0,1,2,...], [...], ]; auto first100s = map!(ctake(100))(target); The first argument of std.range.take is the range, this is handy for chaining with UFCS. I think currently curry!take doesn't work because take is not a function (but

Re: A currying function

2012-06-21 Thread Philippe Sigaud
On Tue, Jun 19, 2012 at 2:52 PM, Artur Skawina wrote: > I'm not really sure when you'd want to use this in D. As for Haskell. For example, with a range of ranges and you want to take the first 100 elements of all subranges: alias Curry!take ctake; auto target = [[0,1,2,...], [...], ]; auto fir

Re: A currying function

2012-06-19 Thread Artur Skawina
On 06/18/12 22:24, bearophile wrote: > I think std.functional.curry is badly named because I think it's a "partial > application" (I suggest to rename it). > In Haskell and Scala currying is built-in, this is Haskell, shell (ghci): > > Prelude> let foo x y z = x * 2 + y * 3 + y * 5 > Prelude> let

A currying function

2012-06-18 Thread bearophile
I think std.functional.curry is badly named because I think it's a "partial application" (I suggest to rename it). In Haskell and Scala currying is built-in, this is Haskell, shell (ghci): Prelude> let foo x y z = x * 2 + y * 3 + y * 5 Prelude> let foo1 = foo 5 Prelude> let foo2 = foo1 4 Pre