June 07, 2010 Re: Marketing of D - article topic ideas? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Leandro Lucarella | Leandro Lucarella wrote:
> Please, document this!
>
> http://d.puremagic.com/issues/show_bug.cgi?id=4230
Done.
|
June 07, 2010 Re: Marketing of D - article topic ideas? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jérôme M. Berger | On 06/07/2010 04:35 PM, "Jérôme M. Berger" wrote:
> Andrei Alexandrescu wrote:
>> On 06/07/2010 12:57 PM, "Jérôme M. Berger" wrote:
>>>> Do this in any dynamic language -> FAIL because looping is so slow that you might
>>>> die of old age before it executes. Besides, who wants to do computationally
>>>> intensive, multithreaded work in a dynamic language?
>>>
>>> In python: max (map (max, args)) should have reasonable
>>> performances and is *much* more elegant...
>>
>> I very much doubt that.
>>
> What do you doubt? That it has reasonable performance or that it is
> more elegant?
That it has reasonable performance. Then, there are a number of things that can't be compared such as figuring out the tightest static types, something that Python doesn't worry about (at the expense of precision and performance).
I see such examples as simple illustrations "look, if you give up X, you gain Y!" - just coming without mentioning X.
Andrei
|
June 07, 2010 Re: Marketing of D - article topic ideas? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky | "Nick Sabalausky" <a@a.a> wrote in message news:hujd9m$11of$1@digitalmars.com... > "Nick Sabalausky" <a@a.a> wrote in message news:hujd6a$11e8$1@digitalmars.com... >> >> Assuming, of course, a 'max' that works on a range, which would be easy enough to do. Probably something like: >> > > ElementType!T max(T range) // Corrected > >> { >> return reduce!ordinaryMax(range); >> // Or >> return reduce!"a>b?a:b"(range); >> } >> > Or: alias reduce!"a>b?a:b" max; God, I love D :) |
June 08, 2010 Re: Marketing of D - article topic ideas? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky | Hello Nick, > "Nick Sabalausky" <a@a.a> wrote in message > news:hujd9m$11of$1@digitalmars.com... > >> "Nick Sabalausky" <a@a.a> wrote in message >> news:hujd6a$11e8$1@digitalmars.com... >> >>> Assuming, of course, a 'max' that works on a range, which would be >>> easy enough to do. Probably something like: >>> >> ElementType!T max(T range) // Corrected >> >>> { >>> return reduce!ordinaryMax(range); >>> // Or >>> return reduce!"a>b?a:b"(range); >>> } > Or: > > alias reduce!"a>b?a:b" max; > > God, I love D :) > so we have: alias reduce!"a>b?a:b" range_max; CommonType!(staticMap!(ElementType, T)) largestElement(T...)(T args) { static assert( !is(typeof(return) == void) ); return max( map!max(args) ); } Why isn't that just one line, like: alias polyMapReduce!(reduce!"a>b?a:b", "a>b?a:b") largestElelemt; I'm shure a better one could be written but I think this would do it: auto polyMapReduce(alias map, string reduce, T...)(T t) { static assert(T.length > 0); static if(T.length > 1) { auto a = map(t[0]); auto b = polyMapReduce!(map,reduce)(t[1..$]); return mixin(reduce); } else return map(t[0]); } -- ... <IXOYE>< |
June 08, 2010 Re: Marketing of D - article topic ideas? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright, el 7 de junio a las 14:42 me escribiste: > Leandro Lucarella wrote: > >Please, document this! > > > >http://d.puremagic.com/issues/show_bug.cgi?id=4230 > > Done. Thanks =) -- Leandro Lucarella (AKA luca) http://llucax.com.ar/ ---------------------------------------------------------------------- GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05) ---------------------------------------------------------------------- Es mejor probar el sabor de sapo y darse cuenta que es feo, antes que no hacerlo y creer que es una gran gomita de pera. -- Dr Ricardo Vaporesso, Malta 1951 |
June 08, 2010 Re: Marketing of D - article topic ideas? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky | Mon, 07 Jun 2010 18:16:15 -0400, Nick Sabalausky wrote:
> "Nick Sabalausky" <a@a.a> wrote in message news:hujd9m$11of$1@digitalmars.com...
>> "Nick Sabalausky" <a@a.a> wrote in message news:hujd6a$11e8$1@digitalmars.com...
>>>
>>> Assuming, of course, a 'max' that works on a range, which would be easy enough to do. Probably something like:
>>>
>>>
>> ElementType!T max(T range) // Corrected
>>
>>> {
>>> return reduce!ordinaryMax(range);
>>> // Or
>>> return reduce!"a>b?a:b"(range);
>>> }
>>>
>>>
>>
> Or:
>
> alias reduce!"a>b?a:b" max;
>
> God, I love D :)
max = reduce >
FSM, I love <funfunfun>. :)
|
June 08, 2010 Re: Marketing of D - article topic ideas? | ||||
---|---|---|---|---|
| ||||
Posted in reply to retard | On Jun 8, 10 15:55, retard wrote:
> Mon, 07 Jun 2010 18:16:15 -0400, Nick Sabalausky wrote:
>
>> "Nick Sabalausky"<a@a.a> wrote in message
>> news:hujd9m$11of$1@digitalmars.com...
>>> "Nick Sabalausky"<a@a.a> wrote in message
>>> news:hujd6a$11e8$1@digitalmars.com...
>>>>
>>>> Assuming, of course, a 'max' that works on a range, which would be
>>>> easy enough to do. Probably something like:
>>>>
>>>>
>>> ElementType!T max(T range) // Corrected
>>>
>>>> {
>>>> return reduce!ordinaryMax(range);
>>>> // Or
>>>> return reduce!"a>b?a:b"(range);
>>>> }
>>>>
>>>>
>>>
>> Or:
>>
>> alias reduce!"a>b?a:b" max;
>>
>> God, I love D :)
>
> max = reduce>
>
> FSM, I love<funfunfun>. :)
If there's any language allowing defining a max like this, it has implemented reduce (a.k.a. fold) wrongly.
|
June 08, 2010 Re: Marketing of D - article topic ideas? | ||||
---|---|---|---|---|
| ||||
Posted in reply to KennyTM~ | Tue, 08 Jun 2010 19:43:26 +0800, KennyTM~ wrote:
> On Jun 8, 10 15:55, retard wrote:
>> Mon, 07 Jun 2010 18:16:15 -0400, Nick Sabalausky wrote:
>>
>>> "Nick Sabalausky"<a@a.a> wrote in message news:hujd9m$11of$1@digitalmars.com...
>>>> "Nick Sabalausky"<a@a.a> wrote in message news:hujd6a$11e8$1@digitalmars.com...
>>>>>
>>>>> Assuming, of course, a 'max' that works on a range, which would be easy enough to do. Probably something like:
>>>>>
>>>>>
>>>> ElementType!T max(T range) // Corrected
>>>>
>>>>> {
>>>>> return reduce!ordinaryMax(range);
>>>>> // Or
>>>>> return reduce!"a>b?a:b"(range);
>>>>> }
>>>>>
>>>>>
>>>>>
>>> Or:
>>>
>>> alias reduce!"a>b?a:b" max;
>>>
>>> God, I love D :)
>>
>> max = reduce>
>>
>> FSM, I love<funfunfun>. :)
>
> If there's any language allowing defining a max like this, it has implemented reduce (a.k.a. fold) wrongly.
Right, I should not have used the symbol >, but last post was right after I woke up. Let's say it depends on the definition of > :)
|
June 08, 2010 Re: Marketing of D - article topic ideas? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky | On 06/07/2010 05:16 PM, Nick Sabalausky wrote:
> "Nick Sabalausky"<a@a.a> wrote in message
> news:hujd9m$11of$1@digitalmars.com...
>> "Nick Sabalausky"<a@a.a> wrote in message
>> news:hujd6a$11e8$1@digitalmars.com...
>>>
>>> Assuming, of course, a 'max' that works on a range, which would be easy
>>> enough to do. Probably something like:
>>>
>>
>> ElementType!T max(T range) // Corrected
>>
>>> {
>>> return reduce!ordinaryMax(range);
>>> // Or
>>> return reduce!"a>b?a:b"(range);
>>> }
>>>
>>
>
> Or:
>
> alias reduce!"a>b?a:b" max;
>
> God, I love D :)
This is kind of funny. This works because reduce is defined as follows:
template reduce(alias fun)
{
alias Reduce!(fun).reduce reduce;
}
I did that to work around some old compiler bugs that have been since fixed. I'd initially intended to define reduce like this:
Unqual!E reduce(alias fun, E, R)(E seed, R r) { ... }
but that wouldn't have allowed Nick's alias, which is quite useful. So it looks like we have a cool idiom.
Andrei
|
June 08, 2010 Re: Marketing of D - article topic ideas? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | "Andrei Alexandrescu" <SeeWebsiteForEmail@erdani.org> wrote in message news:huld21$15sj$1@digitalmars.com... > On 06/07/2010 05:16 PM, Nick Sabalausky wrote: >> "Nick Sabalausky"<a@a.a> wrote in message news:hujd9m$11of$1@digitalmars.com... >>> "Nick Sabalausky"<a@a.a> wrote in message news:hujd6a$11e8$1@digitalmars.com... >>>> >>>> Assuming, of course, a 'max' that works on a range, which would be easy enough to do. Probably something like: >>>> >>> >>> ElementType!T max(T range) // Corrected >>> >>>> { >>>> return reduce!ordinaryMax(range); >>>> // Or >>>> return reduce!"a>b?a:b"(range); >>>> } >>>> >>> >> >> Or: >> >> alias reduce!"a>b?a:b" max; >> >> God, I love D :) > > This is kind of funny. This works because reduce is defined as follows: > > template reduce(alias fun) > { > alias Reduce!(fun).reduce reduce; > } > > I did that to work around some old compiler bugs that have been since fixed. I'd initially intended to define reduce like this: > > Unqual!E reduce(alias fun, E, R)(E seed, R r) { ... } > > but that wouldn't have allowed Nick's alias, which is quite useful. So it looks like we have a cool idiom. > Template currying ;) Maybe not as flexible as typical currying, but still. Curry...dang, now I'm hungry... Also, what's Unqual? |
Copyright © 1999-2021 by the D Language Foundation