On Friday, 21 January 2022 at 04:08:33 UTC, forkit wrote:
// --
void ProcessRecords
(in int[][int][] recArray, const(string) fname)
{
auto file = File(fname, "w");
scope(exit) file.close;
Appender!string bigString = appender!string;
bigString.reserve(recArray.length);
debug
On Friday, 21 January 2022 at 03:57:01 UTC, H. S. Teoh wrote:
std.array.appender is your friend.
T
:-)
// --
void ProcessRecords
(in int[][int][] recArray, const(string) fname)
{
auto file = File(fname, "w");
scope(exit) file.close;
Appender!string bigString = appender!string;
On Fri, Jan 21, 2022 at 03:50:37AM +, forkit via Digitalmars-d-learn wrote:
[...]
> I might have to use a kindof stringbuilder instead, then write a
> massive string once to the file.
[...]
std.array.appender is your friend.
T
--
Meat: euphemism for dead animal. -- Flora
On Friday, 21 January 2022 at 03:45:08 UTC, forkit wrote:
On Friday, 21 January 2022 at 02:30:35 UTC, Ali Çehreli wrote:
The bigger question is, why did 'formattedRecords' exist at
all? You could have written the output directly to the file.
Oh. this was intentional, as I wanted to write onc
On Friday, 21 January 2022 at 02:30:35 UTC, Ali Çehreli wrote:
The bigger question is, why did 'formattedRecords' exist at
all? You could have written the output directly to the file.
Oh. this was intentional, as I wanted to write once, and only
once, to the file.
The consequence of that d
On Friday, 21 January 2022 at 02:10:34 UTC, Steven Schveighoffer
wrote:
thanks Steven (and Ali too).
On 1/20/22 18:07, forkit wrote:
I have a line of code, that I do NOT want executed when -debug is passed
in.
enforce(!exists(fname), "Oop! That file already exists!");
Is this even possible? (with using -version ..)
The following should do it:
debug {} else {
foo();
}
Ali
On 1/20/22 17:35, forkit wrote:
> module test;
> @safe
Does that make just the following definition @safe or the entire module
@safe? Trying... Yes, I am right. To make the module safe, use the
following syntax:
@safe:
> idArray.reserve(recordsNeeded);
[...]
> idArray ~= x;
On 1/20/22 9:07 PM, forkit wrote:
I have a line of code, that I do NOT want executed when -debug is passed
in.
enforce(!exists(fname), "Oop! That file already exists!");
Is this even possible? (with using -version ..)
`debug` is like a `version` block.
```d
debug {} else {
// code that r
I have a line of code, that I do NOT want executed when -debug is
passed in.
enforce(!exists(fname), "Oop! That file already exists!");
Is this even possible? (with using -version ..)
On Friday, 21 January 2022 at 01:35:40 UTC, forkit wrote:
oops. nasty mistake to make ;-)
module test;
@safe
should be:
module test;
@safe:
On Thursday, 20 January 2022 at 23:49:59 UTC, Ali Çehreli wrote:
so here is final code, in idiomatic D, as far as I can tell ;-)
curious output when using -profile=gc
.. a line referring to:
std.array.Appender!(immutable(char)[]).Appender.Data
std.array.Appender!string.Appender.this
C:\D\
On 1/20/22 6:01 PM, forkit wrote:
On Thursday, 20 January 2022 at 22:31:17 UTC, Steven Schveighoffer wrote:
Because it would allow altering const data.
I'm not sure I understand. At what point in this function is valuesArray
modified, and thus preventing it being passed in with const?
The
On 1/20/22 15:10, Ali Çehreli wrote:
> void foo(const int[]) {} // Idiomatic
As H. S. Teoh would add at this point, that is not idiomatic but the
following are (with different meanings):
void foo(const(int)[]) {} // Idiomatic
void foo(const(int[])) {} // Idiomatic
> void foo(i
On 1/20/22 15:01, forkit wrote:
> On Thursday, 20 January 2022 at 22:31:17 UTC, Steven Schveighoffer wrote:
>>
>> Because it would allow altering const data.
>>
>
> I'm not sure I understand. At what point in this function is valuesArray
> modified, and thus preventing it being passed in with cons
On Thursday, 20 January 2022 at 22:31:17 UTC, Steven
Schveighoffer wrote:
Because it would allow altering const data.
I'm not sure I understand. At what point in this function is
valuesArray modified, and thus preventing it being passed in with
const?
// ---
int[][int][] CreateDataSet
re
On 1/20/22 5:07 PM, forkit wrote:
On Thursday, 20 January 2022 at 21:16:46 UTC, forkit wrote:
Cannot work out why I cannot pass valuesArray in as ref const??
get error: Error: cannot append type `const(int[])[const(int)]` to type
`int[][int][]`
Because it would allow altering const data.
On Thursday, 20 January 2022 at 21:16:46 UTC, forkit wrote:
Cannot work out why I cannot pass valuesArray in as ref const??
get error: Error: cannot append type `const(int[])[const(int)]`
to type `int[][int][]`
// --
int[][int][] CreateDataSet(ref const int[] idArray, ref
const(int[][])
On Thursday, 20 January 2022 at 12:40:09 UTC, Stanislav Blinov
wrote:
Allocating 4 megs to generate 10 numbers??? You can generate a
random number between 99900 and 10.
...
// id needs to be 9 digits, and needs to start with 999
x = uniform(999*10^^6, 10^^9);
On 1/20/22 8:28 AM, Paul Backus wrote:
The explanation you quoted is from 2005, and `inout` does not mean the
same thing in 2022 as it did in 2005.
The current meaning of inout is explained in the D language
specification on dlang.org. Here is a link to the relevant section:
https://dlang
On Thu, Jan 20, 2022 at 07:10:40PM +, Jerry via Digitalmars-d-learn wrote:
> Hello, followed the guide at https://wiki.dlang.org/Build_D_for_Android
> but got stuck on figuring out what linker to use.
>
> "../ldc_android/ldc/bin/ldc2.exe" -mtriple=armv7a--linux-andro
> ideabi main.d
> clang: e
Hello, followed the guide at
https://wiki.dlang.org/Build_D_for_Android
but got stuck on figuring out what linker to use.
"../ldc_android/ldc/bin/ldc2.exe" -mtriple=armv7a--linux-andro
ideabi main.d
clang: error: invalid linker name in argument '-fuse-ld=bfd'
Error:
ldc_android/android_ndk/tool
On 1/19/22 21:24, Salih Dincer wrote:
> ```d
>size_t length() inout {
> //return last_ - first_ + 1 - empty_;/*
> auto len = 1 + last_ - first_;
> return cast(size_t)len;//*/
>}
> ```
Good catch but we can't ignore '- empty_'. Otherwise an empty range will
return 1.
> B
On Thursday, 20 January 2022 at 13:28:54 UTC, Paul Backus wrote:
On Thursday, 20 January 2022 at 13:19:06 UTC, Sergey wrote:
[...]
The explanation you quoted is from 2005, and `inout` does not
mean the same thing in 2022 as it did in 2005.
The current meaning of inout is explained in the D
On Friday, 14 January 2022 at 17:48:41 UTC, kyle wrote:
```d
void main()
{
import std.stdio;
Broke foo = Broke(10);
Broke bar = Broke(20);
writeln(foo + 15); //prints 25 as expected
writeln(foo + bar); //prints 20
}
```
I guess what you want to do is something like this:
On Thursday, 20 January 2022 at 13:19:06 UTC, Sergey wrote:
https://forum.dlang.org/post/17nwtnp4are5q$.1ddtvmj4e23iy@40tude.net
On Tuesday, 10 May 2005 at 01:06:14 UTC, Derek Parnell wrote:
[...]
Thanks a lot for your explanation.
I started to learn D language recently and I have trouble
https://forum.dlang.org/post/17nwtnp4are5q$.1ddtvmj4e23iy@40tude.net
On Tuesday, 10 May 2005 at 01:06:14 UTC, Derek Parnell wrote:
On Tue, 10 May 2005 00:30:57 + (UTC), Oliver wrote:
Hello D-ers
The documentation is very short on the keywords in, out and
inout.
Is is inout sth like a
On Thursday, 20 January 2022 at 12:15:56 UTC, forkit wrote:
void createUniqueIDArray(ref int[] idArray, int recordsNeeded)
{
idArray.reserve(recordsNeeded);
debug { writefln("idArray.capacity is %s",
idArray.capacity); }
// id needs to be 9 digits, and needs to start with 999
On Thursday, 20 January 2022 at 10:11:10 UTC, bauss wrote:
Don't make them random then, but use an incrementor.
If you can have ids that aren't integers then you could use
uuids too.
https://dlang.org/phobos/std_uuid.html
The 'uniqueness' of id would actually be created in the database.
On Thursday, 20 January 2022 at 04:00:59 UTC, forkit wrote:
On Thursday, 20 January 2022 at 00:30:44 UTC, H. S. Teoh wrote:
Do the id's have to be unique?
yep...
Don't make them random then, but use an incrementor.
If you can have ids that aren't integers then you could use uuids
too.
30 matches
Mail list logo