On Saturday, 24 January 2015 at 14:53:02 UTC, Andrei Alexandrescu
wrote:
On 1/24/15 3:50 AM, Peter Alexander wrote:
On Friday, 23 January 2015 at 18:22:08 UTC, zeljkog wrote:
On 23.01.15 19:13, Andrei Alexandrescu wrote:
On 1/23/15 10:05 AM, zeljkog wrote:
On 23.01.15 18:48, H. S. Teoh via Di
On Sat, Jan 24, 2015 at 11:20:55AM -0800, Andrei Alexandrescu via Digitalmars-d
wrote:
> On 1/24/15 11:00 AM, H. S. Teoh via Digitalmars-d wrote:
> >On Sat, Jan 24, 2015 at 10:35:13AM -0800, Andrei Alexandrescu via
> >Digitalmars-d wrote:
[...]
> >>For filter it's a forward range if input is forw
On 24.01.15 19:47, Andrei Alexandrescu wrote:
>>
>> But here there is potential problem with shared state after save?
>
> It's not a problem - save saves the state of the iteration, not the data
> being iterated. -- Andrei
>
If you pass stateful object with opCall or closure it becomes part of
On 1/24/15 11:00 AM, H. S. Teoh via Digitalmars-d wrote:
On Sat, Jan 24, 2015 at 10:35:13AM -0800, Andrei Alexandrescu via Digitalmars-d
wrote:
On 1/24/15 9:34 AM, zeljkog wrote:
On 24.01.15 18:26, zeljkog wrote:
Until now I concluded:
1. Resulting range must be output range. Right?
Should
On Sat, Jan 24, 2015 at 10:35:13AM -0800, Andrei Alexandrescu via Digitalmars-d
wrote:
> On 1/24/15 9:34 AM, zeljkog wrote:
> >On 24.01.15 18:26, zeljkog wrote:
> >>
> >>Until now I concluded:
> >>1. Resulting range must be output range. Right?
> >Should be input range.
>
> For filter it's a forw
On 1/24/15 10:41 AM, zeljkog wrote:
On 24.01.15 19:35, Andrei Alexandrescu wrote:
On 1/24/15 9:34 AM, zeljkog wrote:
On 24.01.15 18:26, zeljkog wrote:
Until now I concluded:
1. Resulting range must be output range. Right?
Should be input range.
For filter it's a forward range if input is f
On 24.01.15 19:35, Andrei Alexandrescu wrote:
On 1/24/15 9:34 AM, zeljkog wrote:
On 24.01.15 18:26, zeljkog wrote:
Until now I concluded:
1. Resulting range must be output range. Right?
Should be input range.
For filter it's a forward range if input is forward or better. -- Andrei
But he
On 1/24/15 9:34 AM, zeljkog wrote:
On 24.01.15 18:26, zeljkog wrote:
Until now I concluded:
1. Resulting range must be output range. Right?
Should be input range.
For filter it's a forward range if input is forward or better. -- Andrei
On 24.01.15 18:26, zeljkog wrote:
Until now I concluded:
1. Resulting range must be output range. Right?
Should be input range.
On 24.01.15 18:02, Andrei Alexandrescu wrote:
> On 1/24/15 7:17 AM, zeljkog wrote:
>>
>> private struct FilterResult(alias predicate, Range)
>> {
>> static if (is(predicate == struct))
>> predicate pred;
>> else
>> alias pred = predicate;
>> ...
>
> The problem is here
On 1/24/15 7:17 AM, zeljkog wrote:
private struct FilterResult(alias predicate, Range)
{
static if (is(predicate == struct))
predicate pred;
else
alias pred = predicate;
...
The problem is here - the creation of an empty object is unlikely to be
of use to the calle
The problem with RedBlackTree is that it's cache-unfriendly due
to the
memory allocation and per-node pointers. One reason quicksort
performs
so well is because it works in-place, and the partition
operation
accesses elements bilinearly (i.e., two linear traversals over
the same
stretch of me
On 24.01.15 16:17, zeljkog wrote:
> template filter(alias predicate) if (is(typeof(unaryFun!predicate)))
Should be:
template filter(alias predicate)
if (is(typeof(unaryFun!predicate)) || is(predicate == struct))
On 24.01.15 15:53, Andrei Alexandrescu wrote:
On 1/24/15 4:13 AM, zeljkog wrote:
On 24.01.15 12:50, Peter Alexander wrote:
auto f = unique();
[1, 5, 5, 2, 1, 5, 6, 6].filter!(f).writeln; // [1, 5, 2, 6]
Filter needs an alias, and you cannot alias an R-value (it has no
symbol).
Yes, I see :)
On 1/24/15 4:13 AM, zeljkog wrote:
On 24.01.15 12:50, Peter Alexander wrote:
auto f = unique();
[1, 5, 5, 2, 1, 5, 6, 6].filter!(f).writeln; // [1, 5, 2, 6]
Filter needs an alias, and you cannot alias an R-value (it has no symbol).
Yes, I see :)
But I think this should be supported by std.a
On 1/24/15 3:50 AM, Peter Alexander wrote:
On Friday, 23 January 2015 at 18:22:08 UTC, zeljkog wrote:
On 23.01.15 19:13, Andrei Alexandrescu wrote:
On 1/23/15 10:05 AM, zeljkog wrote:
On 23.01.15 18:48, H. S. Teoh via Digitalmars-d wrote:
I think what he's trying to do is to call a function
On 24.01.15 12:50, Peter Alexander wrote:
> auto f = unique();
> [1, 5, 5, 2, 1, 5, 6, 6].filter!(f).writeln; // [1, 5, 2, 6]
>
> Filter needs an alias, and you cannot alias an R-value (it has no symbol).
Yes, I see :)
But I think this should be supported by std.algorithm:
import std.stdio, st
On Friday, 23 January 2015 at 18:22:08 UTC, zeljkog wrote:
On 23.01.15 19:13, Andrei Alexandrescu wrote:
On 1/23/15 10:05 AM, zeljkog wrote:
On 23.01.15 18:48, H. S. Teoh via Digitalmars-d wrote:
I think what he's trying to do is to call a function that
returns a
delegate, and use that deleg
Ignore me, sorry! Obviously that will not work for reuse of
unique.
import std.stdio, std.algorithm;
auto unique(){
bool[int] c;
return (int a){
if (a in c)
return false;
else{
c[a] = true;
return true;
}
};
}
void main()
{
[1, 5, 5, 2, 1, 5, 6, 6].filter!(unique()).writeln;
}
Just a
On 23.01.15 19:05, zeljkog wrote:
> On 23.01.15 18:48, H. S. Teoh via Digitalmars-d wrote:
>>
>> I think what he's trying to do is to call a function that returns a
>> delegate, and use that delegate to instantiate the filter template.
>> AFAIK I've never seen code like this before, and it looks li
On 23.01.15 19:13, Andrei Alexandrescu wrote:
On 1/23/15 10:05 AM, zeljkog wrote:
On 23.01.15 18:48, H. S. Teoh via Digitalmars-d wrote:
I think what he's trying to do is to call a function that returns a
delegate, and use that delegate to instantiate the filter template.
AFAIK I've never seen
On 1/23/15 10:05 AM, zeljkog wrote:
On 23.01.15 18:48, H. S. Teoh via Digitalmars-d wrote:
I think what he's trying to do is to call a function that returns a
delegate, and use that delegate to instantiate the filter template.
AFAIK I've never seen code like this before, and it looks like the
c
On 23.01.15 18:48, H. S. Teoh via Digitalmars-d wrote:
>
> I think what he's trying to do is to call a function that returns a
> delegate, and use that delegate to instantiate the filter template.
> AFAIK I've never seen code like this before, and it looks like the
> compiler isn't prepared to han
On Fri, Jan 23, 2015 at 09:40:42AM -0800, Andrei Alexandrescu via Digitalmars-d
wrote:
> On 1/23/15 7:04 AM, zeljkog wrote:
> >On 22.01.15 22:40, Andrei Alexandrescu wrote:
> >>There's this classic patter on Unix: |sort|uniq, i.e. sort some data
> >>and only display the unique elements.
> >>
> >
>
On 1/23/15 7:04 AM, zeljkog wrote:
On 22.01.15 22:40, Andrei Alexandrescu wrote:
There's this classic patter on Unix: |sort|uniq, i.e. sort some data and
only display the unique elements.
Loosely-related, compiling
...
auto ret = arr.filter!(myFilter());
...
I got:
Error: closures are not
zeljkog:
Loosely-related, compiling
...
auto ret = arr.filter!(myFilter());
...
I got:
Error: closures are not yet supported in CTFE
Using struct with opCall directly also does not pass.
Did I miss something?
Is it near?
Please show a minimal nonworking example in the D.learn newsgroup.
On 22.01.15 22:40, Andrei Alexandrescu wrote:
There's this classic patter on Unix: |sort|uniq, i.e. sort some data and
only display the unique elements.
Loosely-related, compiling
...
auto ret = arr.filter!(myFilter());
...
I got:
Error: closures are not yet supported in CTFE
Using struct
expensive operation by any means. If there's to be any
> benefit to a sortUniq, it has to be capable of reducing work incurred
> during the sorting process; else you're just going to end up with
> something less efficient.
>
> One solution may be RedBlackTree, which
On Thu, Jan 22, 2015 at 04:33:28PM -0800, Andrei Alexandrescu via Digitalmars-d
wrote:
> On 1/22/15 4:26 PM, H. S. Teoh via Digitalmars-d wrote:
> >The question, though, is whether this hybrid recursion actually wins
> >us anything, since heapsort is known to be somewhat slower than
> >quicksort.
ation could
be quite a bit better than doing the two in sequence.
A few google searches didn't yield much. Ideas?
Thanks,
Andrei
My thought is that uniq on a sorted list is only an O(n)
operation, so it's not an expensive operation by any means. If
there's to be any benef
On 1/22/15 4:26 PM, H. S. Teoh via Digitalmars-d wrote:
The question, though, is whether this hybrid recursion actually wins us
anything, since heapsort is known to be somewhat slower than quicksort.
In the worst case, you choose a poor pivot and get*both* the worst case
of quicksort and the inf
On Thu, Jan 22, 2015 at 04:10:45PM -0800, Andrei Alexandrescu via Digitalmars-d
wrote:
> On 1/22/15 2:51 PM, H. S. Teoh via Digitalmars-d wrote:
> >Wait, if R1 and R3, after the recursion, are sorted and contain only
> >unique elements, doesn't that mean that we can just collapse R2 into
> >a sing
Paul O'Neil:
Is that different than groupBy?
It works with hashing, and doesn't require a sorting, so it's
different. On the other hand it's just few lines of code long,
and it's quite easy to write...
Bye,
bearophile
On 01/22/2015 07:06 PM, bearophile wrote:
> Andrei Alexandrescu:
>
>> What would be a better integrated version - one that does sorting and
>> uniq in one shot? I suspect the combination could be quite a bit
>> better than doing the two in sequence.
>
> What I need most is a "groping by hashing",
On 1/22/15 4:06 PM, bearophile wrote:
Andrei Alexandrescu:
What would be a better integrated version - one that does sorting and
uniq in one shot? I suspect the combination could be quite a bit
better than doing the two in sequence.
What I need most is a "groping by hashing", since years. A u
On 1/22/15 3:52 PM, Vladimir Panteleev wrote:
On Thursday, 22 January 2015 at 23:35:32 UTC, H. S. Teoh via
Digitalmars-d wrote:
On Thu, Jan 22, 2015 at 02:51:38PM -0800, H. S. Teoh via Digitalmars-d
wrote:
Wait, if R1 and R3, after the recursion, are sorted and contain only
unique elements, doe
On 1/22/15 2:51 PM, H. S. Teoh via Digitalmars-d wrote:
Wait, if R1 and R3, after the recursion, are sorted and contain only
unique elements, doesn't that mean that we can just collapse R2 into a
single element along with the endpoints of R1 and R3? So if R1[$-1] <
pivot, then we're done, otherwi
Andrei Alexandrescu:
What would be a better integrated version - one that does
sorting and uniq in one shot? I suspect the combination could
be quite a bit better than doing the two in sequence.
What I need most is a "groping by hashing", since years. A unique
sort can be handy, but it's les
On Thu, Jan 22, 2015 at 11:52:18PM +, Vladimir Panteleev via Digitalmars-d
wrote:
> On Thursday, 22 January 2015 at 23:35:32 UTC, H. S. Teoh via Digitalmars-d
> wrote:
> >On Thu, Jan 22, 2015 at 02:51:38PM -0800, H. S. Teoh via Digitalmars-d
> >wrote:
> >>Wait, if R1 and R3, after the recursio
On Thursday, 22 January 2015 at 22:53:59 UTC, H. S. Teoh via
Digitalmars-d wrote:
So if R1[$-1] < pivot,
This should be always true, no? R1 might be empty, though.
On Thursday, 22 January 2015 at 23:35:32 UTC, H. S. Teoh via
Digitalmars-d wrote:
On Thu, Jan 22, 2015 at 02:51:38PM -0800, H. S. Teoh via
Digitalmars-d wrote:
Wait, if R1 and R3, after the recursion, are sorted and
contain only
unique elements, doesn't that mean that we can just collapse
R2 in
On Thu, Jan 22, 2015 at 02:51:38PM -0800, H. S. Teoh via Digitalmars-d wrote:
> On Thu, Jan 22, 2015 at 02:29:58PM -0800, Andrei Alexandrescu via
> Digitalmars-d wrote:
> [...]
> > Thanks. I'm thinking of something based on general comparisons.
> > Something like a modified quicksort with fat pivo
On Thu, Jan 22, 2015 at 02:29:58PM -0800, Andrei Alexandrescu via Digitalmars-d
wrote:
[...]
> Thanks. I'm thinking of something based on general comparisons.
> Something like a modified quicksort with fat pivot:
>
> A. Partition into three subranges: R1pivot
>
> B. Recurse on R1 obtaining R11,
On 1/22/15 2:06 PM, Justin Whear wrote:
On Thu, 22 Jan 2015 13:40:56 -0800, Andrei Alexandrescu wrote:
There's this classic patter on Unix: |sort|uniq, i.e. sort some data and
only display the unique elements.
What would be a better integrated version - one that does sorting and
uniq in one sh
Andrei Alexandrescu:
There's this classic patter on Unix: |sort|uniq, i.e. sort some
data and only display the unique elements.
In Bugzilla I've asked for a hashGroup, it returns a built-in
associative array.
Bye,
bearophile
On Thu, 22 Jan 2015 13:40:56 -0800, Andrei Alexandrescu wrote:
> There's this classic patter on Unix: |sort|uniq, i.e. sort some data and
> only display the unique elements.
>
> What would be a better integrated version - one that does sorting and
> uniq in one shot? I suspect the combination cou
On Thursday, 22 January 2015 at 21:40:57 UTC, Andrei Alexandrescu
wrote:
There's this classic patter on Unix: |sort|uniq, i.e. sort some
data and only display the unique elements.
What would be a better integrated version - one that does
sorting and uniq in one shot? I suspect the combination
On Thu, Jan 22, 2015 at 01:40:56PM -0800, Andrei Alexandrescu via Digitalmars-d
wrote:
> There's this classic patter on Unix: |sort|uniq, i.e. sort some data
> and only display the unique elements.
>
> What would be a better integrated version - one that does sorting and
> uniq in one shot? I sus
There's this classic patter on Unix: |sort|uniq, i.e. sort some data and
only display the unique elements.
What would be a better integrated version - one that does sorting and
uniq in one shot? I suspect the combination could be quite a bit better
than doing the two in sequence.
A few googl
50 matches
Mail list logo