On Tuesday, July 17, 2012 11:47:07 Christophe Travert wrote:
> The compiler could stop displaying at about 10 failed constrains and
> claim there are more. It would be best if it could figure out what are
> the 10 most interesting constrains, but that may not be easy!
That seems like a good idea.
Jonathan M Davis , dans le message (digitalmars.D:172564), a écrit :
> They're likely to contain a lot of stuff negation of other template
> constraints. For instance,
>
> auto func(R)(R range)
> if(isForwardRange!R && !isBidirectionalRange!R)
> {}
>
> auto func(R)(R range)
> if(isBidire
On Monday, July 16, 2012 22:53:36 Timon Gehr wrote:
> On 07/16/2012 05:22 PM, Don Clugston wrote:
> > On 10/07/12 16:59, Andrei Alexandrescu wrote:
> >> On 7/10/12 9:59 AM, H. S. Teoh wrote:
> >>> On Tue, Jul 10, 2012 at 09:28:51AM -0400, Andrei Alexandrescu wrote:
> On 7/10/12 2:50 AM, Jacob
On 07/16/2012 05:22 PM, Don Clugston wrote:
On 10/07/12 16:59, Andrei Alexandrescu wrote:
On 7/10/12 9:59 AM, H. S. Teoh wrote:
On Tue, Jul 10, 2012 at 09:28:51AM -0400, Andrei Alexandrescu wrote:
On 7/10/12 2:50 AM, Jacob Carlborg wrote:
On 2012-07-09 22:16, Andrei Alexandrescu wrote:
So f
On 10/07/12 16:59, Andrei Alexandrescu wrote:
On 7/10/12 9:59 AM, H. S. Teoh wrote:
On Tue, Jul 10, 2012 at 09:28:51AM -0400, Andrei Alexandrescu wrote:
On 7/10/12 2:50 AM, Jacob Carlborg wrote:
On 2012-07-09 22:16, Andrei Alexandrescu wrote:
So foo is a range of strings, because each elemen
On Monday, July 16, 2012 10:08:11 Jacob Carlborg wrote:
> Just _because_ of how "remove" works in std.algorithm and "erase" in
> C++, I though "sort" behaved similar.
Well, it does in that it sorts in place and returns the result, but the result
and the original are more in line with one another
On 2012-07-16 09:18, Jonathan M Davis wrote:
We do have InPlace in function names when one version of a function operates
in place and another doesn't, but we haven't generally done that on functions
which only have one version, and I don't expect that to change now (at least
not for existing fu
On Monday, July 16, 2012 09:07:06 Jacob Carlborg wrote:
> On 2012-07-16 00:03, Jonathan M Davis wrote:
> > Iterators have exactly the same problem for exactly the same reasons as
> > std.algorithm.remove (e.g. take a look at C++'s erase function). The only
> > way to do this in place would be to cr
On 2012-07-16 00:03, Jonathan M Davis wrote:
Iterators have exactly the same problem for exactly the same reasons as
std.algorithm.remove (e.g. take a look at C++'s erase function). The only way
to do this in place would be to create a separate removeInPlace function
specifically for arrays. But
On Monday, July 16, 2012 01:47:15 Mehrdad wrote:
> On Sunday, 15 July 2012 at 22:39:47 UTC, Jonathan M Davis wrote:
> > On Sunday, July 15, 2012 18:24:47 Andrei Alexandrescu wrote:
> >> On 7/15/12 6:22 PM, Mehrdad wrote:
> >> > On Sunday, 15 July 2012 at 22:03:33 UTC, Jonathan M Davis
> >> >
> >>
On Sunday, 15 July 2012 at 22:39:47 UTC, Jonathan M Davis wrote:
On Sunday, July 15, 2012 18:24:47 Andrei Alexandrescu wrote:
On 7/15/12 6:22 PM, Mehrdad wrote:
> On Sunday, 15 July 2012 at 22:03:33 UTC, Jonathan M Davis
> wrote:
>> auto arr = [10, 22, 19, 4, 6];
>> arr = remove(arr, 3);
>> as
On Sunday, July 15, 2012 18:24:47 Andrei Alexandrescu wrote:
> On 7/15/12 6:22 PM, Mehrdad wrote:
> > On Sunday, 15 July 2012 at 22:03:33 UTC, Jonathan M Davis wrote:
> >> auto arr = [10, 22, 19, 4, 6];
> >> arr = remove(arr, 3);
> >> assert(arr == [10, 22, 19, 6]);
> >
> > Yeah, the problem is th
On 7/15/12 6:22 PM, Mehrdad wrote:
On Sunday, 15 July 2012 at 22:03:33 UTC, Jonathan M Davis wrote:
auto arr = [10, 22, 19, 4, 6];
arr = remove(arr, 3);
assert(arr == [10, 22, 19, 6]);
Yeah, the problem is that this reallocates...
doesn't
On 7/15/12 5:42 PM, Mehrdad wrote:
Another example of how std.algorithm is so hard to use (it's almost
tempting me to start swearing...):
How do you remove an item from an array in place?
It seems so darn simple, and yet it's not in std.algorithm (or
std.range). It makes something so easy so te
On Sunday, 15 July 2012 at 22:03:33 UTC, Jonathan M Davis wrote:
auto arr = [10, 22, 19, 4, 6];
arr = remove(arr, 3);
assert(arr == [10, 22, 19, 6]);
Yeah, the problem is that this reallocates... (not claiming
remove() itself is supposed to be efficient, but this is making
it even
On Sunday, July 15, 2012 23:42:29 Mehrdad wrote:
> Another example of how std.algorithm is so hard to use (it's
> almost tempting me to start swearing...):
>
> How do you remove an item from an array in place?
>
> It seems so darn simple, and yet it's not in std.algorithm (or
> std.range). It mak
Another example of how std.algorithm is so hard to use (it's
almost tempting me to start swearing...):
How do you remove an item from an array in place?
It seems so darn simple, and yet it's not in std.algorithm (or
std.range). It makes something so easy so tedious.
On 07/10/2012 10:48 AM, Simen Kjaeraas wrote:
> On Tue, 10 Jul 2012 16:15:09 +0200, Jacob Carlborg wrote:
>> How do you store your ranges in a struct or class? Most of them are
>> voldemort types.
>
> Well, there is std.range.inputRangeObject, but as the name indicates
As the name "misleads"...
On 2012-07-10 22:13, Christophe Travert wrote:
Then, if the purpose is to make the code efficient, I would use the loop
and append everything to the result without creating the params array,
and even without creating the string p. Appender is made to append
everything directly to it efficiently.
On 11-Jul-12 00:07, Tobias Pankrath wrote:
Given:
@property int delegate() foo(){ ... }
@property int bar(){ ... }
int baz(){ ... }
foo(); // calls the delegate.
bar(); // illegal
baz; // ok, call baz
dmd -property gets every single one of these wrong. -property does _not_
enforce @property
Jacob Carlborg , dans le message (digitalmars.D:171769), a écrit :
> On 2012-07-10 20:04, Andrei Alexandrescu wrote:
>
>> Then store an array. "No one's put a gun to yer head."
>> http://youtu.be/CB1Pij54gTw?t=2m29s
>
> That's what I'm doing.
>
And that's what you should do. Algorithm are not m
"Jonathan M Davis" wrote in message
news:mailman.249.1341951069.31962.digitalmar...@puremagic.com...
> On Tuesday, July 10, 2012 21:07:51 Jacob Carlborg wrote:
>> Second, it would be much easier if it would be possible to better name
>> these ranges, something like interfaces but without polymorp
Jacob Carlborg , dans le message (digitalmars.D:171725), a écrit :
>> To make the best implementation would require to know how the String
>> context works.
>>
> String is a wrapper around str.array.Appender.
Then, if the purpose is to make the code efficient, I would use the loop
and append ever
On Tuesday, July 10, 2012 21:07:51 Jacob Carlborg wrote:
> Second, it would be much easier if it would be possible to better name
> these ranges, something like interfaces but without polymorphism. This
> as been mentioned several times before.
They're templated types. They have to be templated ty
On Tuesday, July 10, 2012 22:04:17 Timon Gehr wrote:
> @property int delegate() foo(){ ... }
> @property int bar(){ ... }
> int baz(){ ... }
>
> foo(); // calls the delegate.
> bar(); // illegal
> baz; // ok, call baz
>
> dmd -property gets every single one of these wrong. -property does _not_
>
Given:
@property int delegate() foo(){ ... }
@property int bar(){ ... }
int baz(){ ... }
foo(); // calls the delegate.
bar(); // illegal
baz; // ok, call baz
dmd -property gets every single one of these wrong. -property
does _not_
enforce @property semantics. It only adds a silly rule that
"Andrei Alexandrescu" wrote in message
news:jthr4a$3f3$1...@digitalmars.com...
>
> I swear I'd just call it "range".
>
> Andrei
>
Sure, why not. http://d.puremagic.com/issues/show_bug.cgi?id=8371
On 07/10/2012 09:36 PM, Jesse Phillips wrote:
On Tuesday, 10 July 2012 at 00:17:12 UTC, Timon Gehr wrote:
I have heard that rumour, but TDPL wisely specifies the behaviour of
the @property attribute as follows:
'In particular "property" is recognized by the the compiler
and signals the fact tha
On Tue, Jul 10, 2012 at 1:22 PM, Jacob Carlborg wrote:
> On 2012-07-10 20:53, Brad Anderson wrote:
>
> For what it's worth:
>>
>> e = 10_000_000
>> a = ((1..e).to_a + (1..e).to_a).sort.uniq.map{ |e| e }
>>
>> Runs in 21,320 ms on my machine with Ruby 1.9.3 whereas:
>>
>> auto end
On Tuesday, 10 July 2012 at 00:17:12 UTC, Timon Gehr wrote:
I have heard that rumour, but TDPL wisely specifies the
behaviour of
the @property attribute as follows:
'In particular "property" is recognized by the the compiler
and signals the fact that the function bearing such an
attribute must
On 2012-07-10 20:53, Brad Anderson wrote:
For what it's worth:
e = 10_000_000
a = ((1..e).to_a + (1..e).to_a).sort.uniq.map{ |e| e }
Runs in 21,320 ms on my machine with Ruby 1.9.3 whereas:
auto end = 10_000_000;
auto a = chain(iota(1, end), iota(1, end)).array()
On 2012-07-10 20:04, Andrei Alexandrescu wrote:
Then store an array. "No one's put a gun to yer head."
http://youtu.be/CB1Pij54gTw?t=2m29s
That's what I'm doing.
--
/Jacob Carlborg
On 2012-07-10 19:30, Jonathan M Davis wrote:
typeof(bar()) x;
works. But regardless, given that you're dealing with a return type which is
auto, there's really no other choice. Even if we weren't using voldemort types
for stuff like map, the return type would still be templated and depend on th
On 2012-07-10 19:55, Andrei Alexandrescu wrote:
Clearly this and any documentation can be improved, but I'd say if it
says "range" there there's no assumption "sorted range" there. I think
the main thing that could be expressed better is "unique consecutive".
Fair enough.
I think it would b
On 2012-07-10 19:23, Daniel Murphy wrote:
writeln([1, 2, 3].map!"a"()[2]);
Sort is in place, and therefore requires more than random access, you need
to be able to modify the data you're operating on.
Something like [3, 4].map!func().selectionSort() could work lazily without
needing to modify
On Tue, Jul 10, 2012 at 3:35 AM, Jacob Carlborg wrote:
> On 2012-07-10 08:59, Dmitry Olshansky wrote:
>
> Can you do it in other languages?
>>
>
> Sure, in Ruby, but that only works on arrays:
>
> p [5, 3, 5, 6, 8].uniq.map{ |e| e.to_s }.sort
>
> Prints:
>
> ["3", "5", "6", "8"]
>
> --
> /Jacob
"Andrei Alexandrescu" wrote in message
news:jthr4a$3f3$1...@digitalmars.com...
> On 7/10/12 2:08 PM, Jonathan M Davis wrote:
>>> That does seem good to have. What would be a better name than makeRange?
>>
>> I see no problem with makeRange. It seems like a sensible name to me.
>> You're
>> takin
On 07/10/2012 08:09 PM, Andrei Alexandrescu wrote:
On 7/10/12 2:08 PM, Jonathan M Davis wrote:
That does seem good to have. What would be a better name than makeRange?
I see no problem with makeRange. It seems like a sensible name to me.
You're
taking a sequence of elements and making a range
On Tue, 10 Jul 2012 16:27:31 +0200, Andrei Alexandrescu
wrote:
On 7/10/12 8:52 AM, Simen Kjaeraas wrote:
bearophile (who else? :p) has suggested the addition of eager and
in-place
versions of some ranges, and I think he has a very good point.
Where would good old loops not work for eager
On Tue, 10 Jul 2012 20:09:15 +0200, Andrei Alexandrescu
wrote:
On 7/10/12 2:08 PM, Jonathan M Davis wrote:
That does seem good to have. What would be a better name than
makeRange?
I see no problem with makeRange. It seems like a sensible name to me.
You're
taking a sequence of elements
On 7/10/12 2:02 PM, Simen Kjaeraas wrote:
On Tue, 10 Jul 2012 17:21:14 +0200, Christophe Travert
wrote:
"Simen Kjaeraas" , dans le message (digitalmars.D:171678), a écrit :
Well, I haven't been able to use a single function from std.algorithm
without adding a lot of calls to "array" or "to!(s
On 7/10/12 2:08 PM, Jonathan M Davis wrote:
That does seem good to have. What would be a better name than makeRange?
I see no problem with makeRange. It seems like a sensible name to me. You're
taking a sequence of elements and making a range out of them.
I swear I'd just call it "range".
An
On Tuesday, July 10, 2012 13:58:50 Andrei Alexandrescu wrote:
> On 7/10/12 1:17 PM, Daniel Murphy wrote:
> > "Christophe Travert" wrote in message
> > news:jthmu8$2s5b$1...@digitalmars.com...
> >
> >> "Daniel Murphy" , dans le message (digitalmars.D:171720), a écrit :
> >>> Could it be extended to
On 7/10/12 1:05 PM, Jacob Carlborg wrote:
On 2012-07-10 16:22, Andrei Alexandrescu wrote:
It may be the case you're trying to write ruby in D. I rarely need to
convert stuff to arrays.
Mostly I receive an array, do some operations on it and then want to
store the result in an instance variabl
On Tue, 10 Jul 2012 17:21:14 +0200, Christophe Travert
wrote:
"Simen Kjaeraas" , dans le message (digitalmars.D:171678), a écrit :
Well, I haven't been able to use a single function from std.algorithm
without adding a lot of calls to "array" or "to!(string)". I think the
things I'm trying to
On 7/10/12 12:57 PM, Jacob Carlborg wrote:
On 2012-07-10 16:36, Dmitry Olshansky wrote:
Dunno, to me it says SORTED in one big scary thought. Again it should
ether check constraint or put some more useful description. e.g.
"(functionality akin to the uniq system utility)" doesn't strike me as
he
On 7/10/12 1:17 PM, Daniel Murphy wrote:
"Christophe Travert" wrote in message
news:jthmu8$2s5b$1...@digitalmars.com...
"Daniel Murphy" , dans le message (digitalmars.D:171720), a écrit :
Could it be extended to accept multiple values? (sort of like chain)
eg.
foreach(x; makeRange(23, 7, 1990)
On 7/10/12 12:38 PM, Jacob Carlborg wrote:
Can't "map" and "filter" return a random-access range if that's what
they receive?
(replied to by others)
Now I understand if you come from a place where there's no concern over
hidden allocations and extra work for the benefit of convenience, you
ma
On Tue, 10 Jul 2012 16:15:09 +0200, Jacob Carlborg wrote:
On 2012-07-10 14:53, Dmitry Olshansky wrote:
Too bad, as there is no need to make an array when you map something.
How do you store your ranges in a struct or class? Most of them are
voldemort types.
Well, there is std.range.inpu
"Christophe Travert" wrote in message
news:jthp14$30em$1...@digitalmars.com...
> "Daniel Murphy" , dans le message (digitalmars.D:171741), a écrit :
>> "Christophe Travert" wrote in message
>> news:jthmu8$2s5b$1...@digitalmars.com...
>>> "Daniel Murphy" , dans le message (digitalmars.D:171720),
"Daniel Murphy" , dans le message (digitalmars.D:171741), a écrit :
> "Christophe Travert" wrote in message
> news:jthmu8$2s5b$1...@digitalmars.com...
>> "Daniel Murphy" , dans le message (digitalmars.D:171720), a écrit :
>>> Could it be extended to accept multiple values? (sort of like chain)
>>
On Tuesday, July 10, 2012 14:27:14 Simen Kjaeraas wrote:
> On Tue, 10 Jul 2012 09:04:31 +0200, Jonathan M Davis
>
> wrote:
> > The problem is that map is lazy, so it can't be a random access range,
>
> Sure it can. If the underlying range is random-access or bidirectional,
> so can map be. What
On Tuesday, July 10, 2012 12:22:30 Andrei Alexandrescu wrote:
> On 7/10/12 12:01 PM, Christophe Travert wrote:
> > Andrei Alexandrescu , dans le message (digitalmars.D:171717), a écrit :
> >> auto singletonRange(E)(E value)
> >> {
> >>
> >> return repeat(value).takeExactly(1);
> >>
> >> }
> >
>
On Tuesday, July 10, 2012 18:57:25 Jacob Carlborg wrote:
> On 2012-07-10 16:36, Dmitry Olshansky wrote:
> > typeof to the rescue. In fact I'm not so proud of voldemort types. As
> > when you need to sotre range somewhere they stand in your way for no
> > benefit.
>
> I'm not exactly sure how you m
"Jacob Carlborg" wrote in message
news:jthnlo$2tjg$1...@digitalmars.com...
> On 2012-07-10 18:42, Daniel Murphy wrote:
>> "Jacob Carlborg" wrote in message
>> news:jthlpf$2pnb$1...@digitalmars.com...
>>>
>>> Can't "map" and "filter" return a random-access range if that's what
>>> they
>>> recei
Jacob Carlborg , dans le message (digitalmars.D:171739), a écrit :
> On 2012-07-10 18:42, Daniel Murphy wrote:
>> "Jacob Carlborg" wrote in message
>> news:jthlpf$2pnb$1...@digitalmars.com...
>>>
>>> Can't "map" and "filter" return a random-access range if that's what they
>>> receive?
>>>
>> map
"Christophe Travert" wrote in message
news:jthmu8$2s5b$1...@digitalmars.com...
> "Daniel Murphy" , dans le message (digitalmars.D:171720), a écrit :
>> Could it be extended to accept multiple values? (sort of like chain)
>> eg.
>> foreach(x; makeRange(23, 7, 1990)) // NO allocations!
>> {
>>
On 2012-07-10 18:42, Daniel Murphy wrote:
"Jacob Carlborg" wrote in message
news:jthlpf$2pnb$1...@digitalmars.com...
Can't "map" and "filter" return a random-access range if that's what they
receive?
map can, and does.
It doesn't seem to:
auto a = [3, 4].map!(x => x);
auto b = a.sort;
Re
On 2012-07-10 16:22, Andrei Alexandrescu wrote:
It may be the case you're trying to write ruby in D. I rarely need to
convert stuff to arrays.
Mostly I receive an array, do some operations on it and then want to
store the result in an instance variable in a class or struct. It's
quite awkwar
Jacob Carlborg , dans le message (digitalmars.D:171725), a écrit :
> On 2012-07-10 17:11, Christophe Travert wrote:
>
>> What is wrong with foo.chain(["bar"])?
>
> I think it conceptually wrong for what I want to do. I don't know if I
> misunderstood ranges completely but I'm seeing them as an a
"Daniel Murphy" , dans le message (digitalmars.D:171720), a écrit :
> Could it be extended to accept multiple values? (sort of like chain)
> eg.
> foreach(x; makeRange(23, 7, 1990)) // NO allocations!
> {
>
> }
> I would use this in a lot of places I currently jump through hoops to get a
On 2012-07-10 16:36, Dmitry Olshansky wrote:
typeof to the rescue. In fact I'm not so proud of voldemort types. As
when you need to sotre range somewhere they stand in your way for no
benefit.
I'm not exactly sure how you mean but this is what I came up with:
import std.algorithm;
import std.
Andrei Alexandrescu , dans le message (digitalmars.D:171723), a écrit :
>> auto emptyRange(E)(E value)
>> {
>>return repeat(value).takeNone;
>> }
> That also seems to answer Jonathan's quest about defining emptyRange.
> Just use takeNone(R.init).
err, that should be more like:
auto singleto
On 07/10/2012 06:40 PM, Jacob Carlborg wrote:
On 2012-07-10 16:54, Andrei Alexandrescu wrote:
Actually I take that back. One may use uniq to remove duplicates in
unsorted ranges.
How does that work? It didn't work in my example.
It works. It removes consecutive duplicates. 'uniq' in ruby i
"Jacob Carlborg" wrote in message
news:jthlpf$2pnb$1...@digitalmars.com...
>
> Can't "map" and "filter" return a random-access range if that's what they
> receive?
>
map can, and does.
filter cannot, because it doesn't know which element is number 4 until it
knows if element 3 is included or no
On 07/10/2012 06:38 PM, Jacob Carlborg wrote:
On 2012-07-10 17:30, Andrei Alexandrescu wrote:
It would be possible to chain a single element to the end of a range.
One related thing to do is to define singletonRange(x) that returns a
range with exactly one element, namely x.
Ok, I saw that su
On 2012-07-10 16:54, Andrei Alexandrescu wrote:
Actually I take that back. One may use uniq to remove duplicates in
unsorted ranges.
How does that work? It didn't work in my example.
--
/Jacob Carlborg
On 2012-07-10 17:30, Andrei Alexandrescu wrote:
It would be possible to chain a single element to the end of a range.
One related thing to do is to define singletonRange(x) that returns a
range with exactly one element, namely x.
Ok, I saw that suggestion in another post.
Ranges and std.algo
On 2012-07-10 17:11, Christophe Travert wrote:
What is wrong with foo.chain(["bar"])?
I think it conceptually wrong for what I want to do. I don't know if I
misunderstood ranges completely but I'm seeing them as an abstraction
over a collection. With most mutable collection you can add/appen
On 2012-07-10 16:49, Dmitry Olshansky wrote:
I'm not sure how map can fit there. If anything you need a foreach (and
you have it;) ) to build a _string_. I'd rather output ',' right there
inside of loop. Thus avoiding costly join and appending to a new buffer
on each iteration.
Sure if remove
On 7/10/12 12:01 PM, Christophe Travert wrote:
Andrei Alexandrescu , dans le message (digitalmars.D:171717), a écrit :
auto singletonRange(E)(E value)
{
return repeat(value).takeExactly(1);
}
It would be much better to use:
auto singletonRange(E)(E value)
{
return repeat(value).ta
Andrei Alexandrescu , dans le message (digitalmars.D:171717), a écrit :
> On 7/10/12 11:11 AM, Christophe Travert wrote:
>> If you do not want the heap allocation of the array, you can create a
>> one-element range to feed to chain (maybe such a thing could be placed
>> in phobos, next to takeOne).
"Andrei Alexandrescu" wrote in message
news:jthiba$2cg0$1...@digitalmars.com...
> On 7/10/12 11:11 AM, Christophe Travert wrote:
>> If you do not want the heap allocation of the array, you can create a
>> one-element range to feed to chain (maybe such a thing could be placed
>> in phobos, next to
On Tuesday, July 10, 2012 15:21:14 Christophe Travert wrote:
> "Simen Kjaeraas" , dans le message (digitalmars.D:171678), a écrit :
> >> Well, I haven't been able to use a single function from std.algorithm
> >> without adding a lot of calls to "array" or "to!(string)". I think the
> >> things I'm
On 7/10/12 11:11 AM, Christophe Travert wrote:
If you do not want the heap allocation of the array, you can create a
one-element range to feed to chain (maybe such a thing could be placed
in phobos, next to takeOne).
struct OneElementRange(E)
{
E elem;
bool passed;
@property ref E front
Jacob Carlborg , dans le message (digitalmars.D:171690), a écrit :
>> int[] arr = [ 1, 2, 2, 2, 2, 3, 4, 4, 4, 5 ];
>> assert(equal(uniq(arr), [ 1, 2, 3, 4, 5 ][]));
>
> How should I know that from the example?
Maybe there should be an example with an unsorted range, and a better
explanation:
On 7/10/12 11:17 AM, Jonathan M Davis wrote:
On Tuesday, July 10, 2012 10:21:23 Andrei Alexandrescu wrote:
On 7/10/12 5:35 AM, Jacob Carlborg wrote:
On 2012-07-10 08:59, Dmitry Olshansky wrote:
Can you do it in other languages?
Sure, in Ruby, but that only works on arrays:
p [5, 3, 5, 6, 8]
On 7/10/12 9:56 AM, Jacob Carlborg wrote:
On 2012-07-10 15:28, Andrei Alexandrescu wrote:
We can arrange things in the library that a custom message is issued, or
in the compiler to do it once for all. At any rate whenever there's an
error pointing somewhere in the library's code that's an insu
"Simen Kjaeraas" , dans le message (digitalmars.D:171678), a écrit :
>> Well, I haven't been able to use a single function from std.algorithm
>> without adding a lot of calls to "array" or "to!(string)". I think the
>> things I'm trying to do seems trivial and quite common. I'm I overrating
>
Dmitry Olshansky , dans le message (digitalmars.D:171679), a écrit :
> Because uniq work only on sorted ranges? Have you tried reading docs?
> "
> Iterates unique consecutive elements of the given range (functionality
> akin to the uniq system utility). Equivalence of elements is assessed by
> us
On Tuesday, July 10, 2012 10:21:23 Andrei Alexandrescu wrote:
> On 7/10/12 5:35 AM, Jacob Carlborg wrote:
> > On 2012-07-10 08:59, Dmitry Olshansky wrote:
> >> Can you do it in other languages?
> >
> > Sure, in Ruby, but that only works on arrays:
> >
> > p [5, 3, 5, 6, 8].uniq.map{ |e| e.to_s }.
Jacob Carlborg , dans le message (digitalmars.D:171685), a écrit :
> I mean, is it possible to have the original code work?
>
> auto bar = foo.chain("bar");
>
> Or perhaps more appropriate:
>
> auto bar = foo.append("bar");
What is wrong with foo.chain(["bar"])?
If you do not want the heap all
On 10-Jul-12 19:00, Timon Gehr wrote:
On 07/10/2012 02:53 PM, Dmitry Olshansky wrote:
On 10-Jul-12 15:37, Jacob Carlborg wrote:
On 2012-07-10 12:05, Dmitry Olshansky wrote:
and what type has the return of map ? Let me guess - array.
Yes, and that is what I _want_.
Too bad, as there is no
On 07/10/2012 02:53 PM, Dmitry Olshansky wrote:
On 10-Jul-12 15:37, Jacob Carlborg wrote:
On 2012-07-10 12:05, Dmitry Olshansky wrote:
and what type has the return of map ? Let me guess - array.
Yes, and that is what I _want_.
Too bad, as there is no need to make an array when you map some
On 7/10/12 9:59 AM, H. S. Teoh wrote:
On Tue, Jul 10, 2012 at 09:28:51AM -0400, Andrei Alexandrescu wrote:
On 7/10/12 2:50 AM, Jacob Carlborg wrote:
On 2012-07-09 22:16, Andrei Alexandrescu wrote:
So foo is a range of strings, because each element of it is a
string. Then you want to chain a
On 7/10/12 10:26 AM, Andrei Alexandrescu wrote:
On 7/10/12 8:50 AM, Nick Treleaven wrote:
On 10/07/2012 12:37, Jacob Carlborg wrote:
The corresponding D version would be:
auto a = [5, 3, 5, 6, 8].uniq.map!(x => x.to!(string)).array.sort.array;
writeln(a);
I'm guessing that's three allocations
On 10-Jul-12 17:59, H. S. Teoh wrote:
On Tue, Jul 10, 2012 at 09:28:51AM -0400, Andrei Alexandrescu wrote:
On 7/10/12 2:50 AM, Jacob Carlborg wrote:
On 2012-07-09 22:16, Andrei Alexandrescu wrote:
So foo is a range of strings, because each element of it is a
string. Then you want to chain a
On 10-Jul-12 17:56, Jacob Carlborg wrote:
On 2012-07-10 15:28, Andrei Alexandrescu wrote:
We can arrange things in the library that a custom message is issued, or
in the compiler to do it once for all. At any rate whenever there's an
error pointing somewhere in the library's code that's an insu
On 10-Jul-12 18:15, Jacob Carlborg wrote:
On 2012-07-10 14:53, Dmitry Olshansky wrote:
Too bad, as there is no need to make an array when you map something.
How do you store your ranges in a struct or class? Most of them are
voldemort types.
typeof to the rescue. In fact I'm not so proud o
On 7/10/12 8:52 AM, Simen Kjaeraas wrote:
bearophile (who else? :p) has suggested the addition of eager and in-place
versions of some ranges, and I think he has a very good point.
Where would good old loops not work for eager stuff?
Andrei
On 7/10/12 8:50 AM, Nick Treleaven wrote:
On 10/07/2012 12:37, Jacob Carlborg wrote:
The corresponding D version would be:
auto a = [5, 3, 5, 6, 8].uniq.map!(x => x.to!(string)).array.sort.array;
writeln(a);
I'm guessing that's three allocations. But that doesn't even work, it
prints:
["3", "
On 7/10/12 8:27 AM, Simen Kjaeraas wrote:
On Tue, 10 Jul 2012 09:04:31 +0200, Jonathan M Davis
wrote:
The problem is that map is lazy, so it can't be a random access range,
Sure it can. If the underlying range is random-access or bidirectional,
so can map be. What can't be (as easily) done i
On 7/10/12 5:41 AM, Jacob Carlborg wrote:
Well, I haven't been able to use a single function from std.algorithm
without adding a lot of calls to "array" or "to!(string)". I think the
things I'm trying to do seems trivial and quite common. I'm I overrating
std.algorithm or does it not fit my needs
On 7/10/12 5:35 AM, Jacob Carlborg wrote:
On 2012-07-10 08:59, Dmitry Olshansky wrote:
Can you do it in other languages?
Sure, in Ruby, but that only works on arrays:
p [5, 3, 5, 6, 8].uniq.map{ |e| e.to_s }.sort
This is very inefficient.
I agree that if efficiency wasn't a concern for st
On 2012-07-10 14:53, Dmitry Olshansky wrote:
Too bad, as there is no need to make an array when you map something.
How do you store your ranges in a struct or class? Most of them are
voldemort types.
Then you need something like transform. Anyway the result of map should
be sortable it's a
On 2012-07-10 14:50, Nick Treleaven wrote:
uniq needs sorted input:
auto r = [5, 3, 5, 6, 8].sort.uniq.map!(x => x.to!string);
writeln(r);
Tested with dmd 2.059.
I think the above should be one allocation (except for the strings).
But I want the result to be an array, which would require an
On 2012-07-10 14:55, Dmitry Olshansky wrote:
Maybe uniq should require a SortedRange?
And say so explicitly in the docs.
Than it should be enforced with a constraint (if possible).
--
/Jacob Carlborg
On 2012-07-10 15:28, Andrei Alexandrescu wrote:
We can arrange things in the library that a custom message is issued, or
in the compiler to do it once for all. At any rate whenever there's an
error pointing somewhere in the library's code that's an insufficient
template constraint that should be
On Tue, Jul 10, 2012 at 09:28:51AM -0400, Andrei Alexandrescu wrote:
> On 7/10/12 2:50 AM, Jacob Carlborg wrote:
> >On 2012-07-09 22:16, Andrei Alexandrescu wrote:
> >
> >>So foo is a range of strings, because each element of it is a
> >>string. Then you want to chain a range of strings with a str
On 7/10/12 3:48 AM, Jonathan M Davis wrote:
On Monday, July 09, 2012 16:16:42 Andrei Alexandrescu wrote:
Another example:
auto str = ["foo", "bar"].map!(x => x);
auto f = str.sort();
Results in:
http://pastebin.com/BeePWQk9
The first error message is at clear as it goes:
Error: r[i2] is n
1 - 100 of 137 matches
Mail list logo