On 10/18/18 10:08 AM, aliak wrote:
On Wednesday, 17 October 2018 at 23:34:55 UTC, Paul Backus wrote:
On Wednesday, 17 October 2018 at 07:32:37 UTC, aliak wrote:
lazy S x = () {
// do some heavy stuff
}();
if (condition) {
func(x.y); // heavy stuff evaluated here
}
auto x = () {
//
On Thursday, 18 October 2018 at 16:10:04 UTC, aliak wrote:
On Thursday, 18 October 2018 at 14:16:56 UTC, Simen Kjærås
wrote:
On Wednesday, 17 October 2018 at 07:32:37 UTC, aliak wrote:
Hi,
Is there any notion of lazy vars in D (i see that there're
parameters)?
What the language doesn't
On Wednesday, 17 October 2018 at 07:32:37 UTC, aliak wrote:
Hi,
Is there any notion of lazy vars in D (i see that there're
parameters)?
What the language doesn't provide, it generally provides the
tools to make:
struct Lazy(T) {
T delegate() _payload;
this(lazy T t) {
On Wednesday, 17 October 2018 at 20:32:40 UTC, Ali Çehreli wrote:
On 10/17/2018 12:32 AM, aliak wrote:
[...]
Not very clean but something like this:
import std.stdio;
struct LazyVar(alias exp) {
alias T = typeof(exp());
T value() {
static bool initialized = false;
On Thursday, 18 October 2018 at 14:16:56 UTC, Simen Kjærås wrote:
On Wednesday, 17 October 2018 at 07:32:37 UTC, aliak wrote:
Hi,
Is there any notion of lazy vars in D (i see that there're
parameters)?
What the language doesn't provide, it generally provides the
tools to make:
struct
On Thursday, 18 October 2018 at 14:11:36 UTC, Steven
Schveighoffer wrote:
Yes, but that's what lazy variables do.
-Steve
Not in Swift at least...
On Thursday, 18 October 2018 at 14:08:11 UTC, aliak wrote:
On Wednesday, 17 October 2018 at 23:34:55 UTC, Paul Backus
wrote:
auto x = () {
// do some heavy stuff
};
if (condition) {
func(x().y); // heavy stuff evaluated here
}
That would do heavy stuff everytime i wanted to get y
On 10/18/18 12:11 PM, aliak wrote:
On Thursday, 18 October 2018 at 14:11:36 UTC, Steven Schveighoffer wrote:
Yes, but that's what lazy variables do.
Not in Swift at least...
Apparently so (I have not used them before), but this is D! So you
should be aware that lazy parameters work that
On Thursday, 18 October 2018 at 18:39:18 UTC, Samir wrote:
which leads me to believe that the output of `uniq` is not
necessarily another integer array.
Right, it is actually a "range" - an object that generates the
result on-demand, so it doesn't do work you don't actually need.
If you
I am working my way through the exercises in the "Programming in
D" tutorial (http://ddili.org/ders/d.en/arrays.html). Why is the
line assigning the length of the dynamic array required?
/*
Write a program that asks the user how many values will be
entered and then
reads all of them. Have
On Friday, 19 October 2018 at 02:04:37 UTC, Samir wrote:
I am working my way through the exercises in the "Programming
in D" tutorial (http://ddili.org/ders/d.en/arrays.html). Why
is the line assigning the length of the dynamic array required?
[...]
Without the line:
myArray.length =
On 10/18/2018 07:04 PM, Samir wrote:
> myArray.length = noValues; // I get a run-time error if I comment
> this out
It's because the expression that reads the elements below is readf,
which reads on top of an existing element.
> while (i < noValues) {
> write("enter value
On Thursday, 18 October 2018 at 18:53:06 UTC, Adam D. Ruppe wrote:
But, if you need to copy it into a new array, use `.array` at
the end.
Thanks. That did the trick. But if I may, what is the
difference between
uniqueArray = uniq(sort(unsortedArray)).array;
and
uniqueArray =
On Thursday, October 18, 2018 4:50:18 AM MDT Paolo Invernizzi via
Digitalmars-d-learn wrote:
> There's a rational behind the fact that there's not a 'shared'
> version of notify/wait method in Condition?
>
> Thanks,
> Paolo
The original author of the stuff in core.sync didn't want to update it
Are there a function like C#'s Path.GetDirectoryName()
(https://docs.microsoft.com/en-us/dotnet/api/system.io.path.getdirectoryname?redirectedfrom=MSDN=netframework-4.7.2#System_IO_Path_GetDirectoryName_System_String_) in D standard library or some dub package?
just checking if there's one, so
On Thursday, 18 October 2018 at 19:54:59 UTC, Dr.No wrote:
Are there a function like C#'s Path.GetDirectoryName()
Looks the same as "dirName" from "import std.path"
http://dpldocs.info/experimental-docs/std.path.dirName.1.html
What is the proper way to find the unique values of an array and
store them in another array? When I try:
import std.stdio: writeln;
import std.conv;
import std.algorithm;
void main() {
int[] unsortedArray = [5, 3, 8, 5, 2, 3, 0, 8];
int[] uniqueArray;
uniqueArray =
On Thursday, 18 October 2018 at 19:25:26 UTC, Adam D. Ruppe wrote:
Which is better simply depends on which one reads better to you.
Thanks again, Adam.
On Thursday, 18 October 2018 at 19:19:53 UTC, Samir wrote:
They both seem to work. Is one preferred over the other?
No difference. The compile will just transform o.f into f(o) if
it can. They both do the same thing and it is just a different
way of writing it.
Which is better simply
On Friday, 19 October 2018 at 02:04:37 UTC, Samir wrote:
I would have thought that since this is a dynamic array, I
don't need to pre-assign its length.
Thanks
Just to expand on the previous answers, a dynamic array
declaration with no initializer is an empty array:
int[] arr;
On 18/10/2018 6:38 PM, dangbinghoo wrote:
hi,
Is there any other documents related about ddoc usage? the only thing I
can find is:
https://dlang.org/spec/ddoc.html#using_ddoc_to_generate_examples
But I found it never mentioned something like $(LI a list item), is
there a full ddoc
On Thursday, 18 October 2018 at 05:59:36 UTC, rikki cattermole
wrote:
On 18/10/2018 6:38 PM, dangbinghoo wrote:
hi,
Is there any other documents related about ddoc usage? the
only thing I can find is:
https://dlang.org/spec/ddoc.html#using_ddoc_to_generate_examples
But I found it never
On Wednesday, 17 October 2018 at 13:48:04 UTC, FrankLike wrote:
Hi,teacher:
I like D lang,when I download the soft from
http://www.360totalsecurity.com/en/
Contact their support: supp...@360safe.com
There's a rational behind the fact that there's not a 'shared'
version of notify/wait method in Condition?
Thanks,
Paolo
On Thursday, 18 October 2018 at 10:50:18 UTC, Paolo Invernizzi
wrote:
There's a rational behind the fact that there's not a 'shared'
version of notify/wait method in Condition?
They were implemented before complete `shared` spec existed,
which is any time between it's conception and now.
On Thursday, 18 October 2018 at 10:50:18 UTC, Paolo Invernizzi
wrote:
There's a rational behind the fact that there's not a 'shared'
version of notify/wait method in Condition?
core.sync is pretty old, it was written in 2009 before default
storage class for global variables became TLS.
On Wednesday, 17 October 2018 at 23:34:55 UTC, Paul Backus wrote:
On Wednesday, 17 October 2018 at 07:32:37 UTC, aliak wrote:
lazy S x = () {
// do some heavy stuff
}();
if (condition) {
func(x.y); // heavy stuff evaluated here
}
auto x = () {
// do some heavy stuff
};
if
On 10/17/18 3:32 AM, aliak wrote:
Hi,
Is there any notion of lazy vars in D (i see that there're parameters)?
i.e:
struct S {
//...
int y;
//...
}
/*
lazy S x = () {
// do some heavy stuff
}();
*/
auto x() { // do some heavy stuff
}
if (condition) {
func(x.y); //
28 matches
Mail list logo