On Thursday, 1 April 2021 at 19:38:39 UTC, H. S. Teoh wrote:
On Thu, Apr 01, 2021 at 04:52:17PM +, Nestor via
Digitalmars-d-learn wrote: [...]
[...]
Since the length of the array is already known beforehand, you
could get significant speedups by preallocating the array
I am a python programmer and I am enjoying Dlang and learning
some programming insights on the way, thank everyone.
I have no formal education and also program JS and PHP.
Watching a video where a guy programs some simple code in Python
and the same code in Go and compares speed I thought
On Sunday, 12 February 2017 at 05:54:34 UTC, Era Scarecrow wrote:
On Saturday, 11 February 2017 at 21:56:54 UTC, Era Scarecrow
wrote:
Just ran the unittests under the dmd profiler, says the
algorithm is 11% faster now. So yeah slightly more optimized.
Ran some more tests.
Without
On Saturday, 11 February 2017 at 21:41:11 UTC, Era Scarecrow
wrote:
On Saturday, 11 February 2017 at 21:02:40 UTC, Era Scarecrow
wrote:
Yes i know, which is why i had 3 to calculate 2 inputs
because the third is the temp/previous calculation.
Alright I've found the bug and fixed it, and it
On Saturday, 11 February 2017 at 11:45:02 UTC, Era Scarecrow
wrote:
On Friday, 10 February 2017 at 11:27:02 UTC, Nestor wrote:
Thank you for the detailed reply. I wasn't able to follow you
regarding the multilevel stuff though :(
The idea behind it is like this (which you can scale up):
On Thursday, 9 February 2017 at 23:49:19 UTC, Era Scarecrow wrote:
Other optimizations could be to make it multiple levels,
taking the basic 100 elements and expanding them 2-3 levels
deep in a lookup and having it do it in more or less a single
operation. (100 bytes for 1 level, 10,000 for 2
On Thursday, 9 February 2017 at 21:43:08 UTC, Daniel Kozak wrote:
Any idea of what might be happening here?
Did you try it with different backends? llvm (ldc), gcc(gdc)?
Not really, just standard dmd.
I tried running each algoritm a few times through avgtime using
different digit lengths
On Thursday, 9 February 2017 at 20:46:06 UTC, Daniel Kozak wrote:
Maybe you can try use static array instead of dynamic
static immutable ubyte[10][10] QG10Matrix = ...
I shaved it to this to discard unneccessary time-consuming
functions:
static immutable ubyte[10][10] QG10Matrix = [
On Thursday, 9 February 2017 at 18:34:30 UTC, Era Scarecrow wrote:
...
Actually since you're also multiplying by 10, you can
incorporate that in the table too...
I forgot to comment that what is multiplied by ten is not the
value but the starting position in the array (a way to emulate a
On Thursday, 9 February 2017 at 18:34:30 UTC, Era Scarecrow wrote:
On Thursday, 9 February 2017 at 17:36:11 UTC, Nestor wrote:
I was trying to port C code from the article in Wikiversity
[1] to D, but I'm not sure this implementation is the most
efficient way to do it in D, so suggestions to
Hi,
I was trying to port C code from the article in Wikiversity [1]
to D, but I'm not sure this implementation is the most efficient
way to do it in D, so suggestions to optimize it are welcome:
import std.stdio;
static immutable char[] QG10Matrix =
Hi,
Is there a native D implementation of B+ tree anywhere?
So far I have found only std.container.rbtree but I wanted to
compare both algorithms regarding search performance, memory and
cpu usage, and storage space required for serialization.
Thanks in advance.
On Monday, 30 January 2017 at 16:40:47 UTC, biozic wrote:
As an alternative, you could build an object file from Sqlite's
source code (e.g. the amalgamation file from Sqlite's website)
with a C compiler. Then you just build your D application with:
dmd app.d sqlite3.d sqlite3.o[bj]
No dll.
On Monday, 30 January 2017 at 13:58:45 UTC, Adam D. Ruppe wrote:
On Monday, 30 January 2017 at 13:29:20 UTC, Nestor wrote:
OK, and in case I have a sqlite3.a file
Just pass the sqlite3.a file instead of sqlite3.lib and the
compiler should do the rest... worst case is you might need to
edit
On Monday, 30 January 2017 at 13:22:45 UTC, Kagamin wrote:
In general case the library can depend on it being a dll, then
it can't be linked statically.
OK, and in case I have a sqlite3.a file, what parameters should I
pass to dmd to build a static application?
Hi,
In Windows, is it possible embed a dll library into an
application (in this particular case, sqlite3.dll)? Notice I
don't mean storing the resource in the application to extract it
at runtime, but rather to produce a static self-contained
application.
If it's possible, please provide a
On Monday, 30 January 2017 at 03:07:22 UTC, Adam D. Ruppe wrote:
If I specify all source files, there are even more problems:
Error 42: Symbol Undefined _sqlite3_open
It apparently couldn't find sqlite3.lib.
Files sqlite3.{def|dll|lib} are on both source/ and
source/arsd/ (just in case)
On Monday, 30 January 2017 at 02:25:40 UTC, Adam D. Ruppe wrote:
On Monday, 30 January 2017 at 00:06:00 UTC, Nestor wrote:
I wasn't doing it explicitly. However I just did that and
still encountered a few errors, which I removed with this
patch:
Where did you get that ancient version? The
On Sunday, 29 January 2017 at 17:36:45 UTC, Adam D. Ruppe wrote:
On Sunday, 29 January 2017 at 16:26:30 UTC, Nestor wrote:
dmd yourfile.d database.d sqlite.d
I have just tried your way and I get some errors:
Error 42: Symbol Undefined
_D4arsd8database3Row7opIndexMFkAyaiZAya
Are you sure
On Saturday, 28 January 2017 at 19:01:48 UTC, Adam D. Ruppe wrote:
On Friday, 27 January 2017 at 12:01:30 UTC, Nestor wrote:
Is there any other native D implementation of sqlite reader?
My sqlite.d and database.d from here can do it too:
https://github.com/adamdruppe/arsd
Just download those
On Friday, 4 November 2011 at 16:31:30 UTC, Johannes Pfau wrote:
On http://www.digitalmars.com/download/freecompiler.html
there's a link to this file: http://ftp.digitalmars.com/bup.zip
I think that's the implib you want?
I just tried implib with latest sqlite library def (windows x86)
like
On Sunday, 29 January 2017 at 03:11:34 UTC, Stefan Koch wrote:
On Sunday, 29 January 2017 at 02:59:12 UTC, Nestor wrote:
On Sunday, 29 January 2017 at 02:55:04 UTC, Adam D. Ruppe
wrote:
On Sunday, 29 January 2017 at 00:36:34 UTC, Nestor wrote:
Well, native implementations are useful at least
On Sunday, 29 January 2017 at 02:55:04 UTC, Adam D. Ruppe wrote:
On Sunday, 29 January 2017 at 00:36:34 UTC, Nestor wrote:
Well, native implementations are useful at least for building
self-contained applications.
Sometimes true, but sqlite can be easily embedded and
statically linked, so
On Sunday, 29 January 2017 at 01:53:30 UTC, Stefan Koch wrote:
On Sunday, 29 January 2017 at 01:47:44 UTC, Nestor wrote:
On Saturday, 28 January 2017 at 21:09:25 UTC, Stefan Koch
wrote:
On Saturday, 28 January 2017 at 12:09:35 UTC, Nestor wrote:
On Friday, 27 January 2017 at 12:55:55 UTC,
On Saturday, 28 January 2017 at 21:09:25 UTC, Stefan Koch wrote:
On Saturday, 28 January 2017 at 12:09:35 UTC, Nestor wrote:
On Friday, 27 January 2017 at 12:55:55 UTC, Stefan Koch wrote:
[...]
Thanks. It did compile using dub, though I had a couple of
issues with dub, by the way.
[...]
On Saturday, 28 January 2017 at 19:09:01 UTC, ag0aep6g wrote:
In D, a `char` is a UTF-8 code unit. Its size is one byte,
exactly and always.
A `char` is not a "character" in the common meaning of the
word. There's a more specialized word for "character" as a
visual unit: grapheme. For
On Sunday, 29 January 2017 at 00:14:02 UTC, Adam D. Ruppe wrote:
On Saturday, 28 January 2017 at 21:03:08 UTC, Stefan Koch wrote:
It's not native though.
It's a mistake to ask for native D implementations of mature C
libraries, especially a public domain one like sqlite. There's
just no
On Saturday, 28 January 2017 at 16:01:38 UTC, Ivan Kazmenko wrote:
As said, the byte count is indeed string.length.
The number of code points can be found by std.range.walkLength,
but be aware it takes O(answer) time to compute.
Example:
-
import std.range, std.stdio;
void main () {
On Friday, 27 January 2017 at 04:26:31 UTC, Era Scarecrow wrote:
Skipping the BOM is just a matter of skipping the first two
bytes identifying it...
AFAIK in some cases the BOM takes up to 4 bytes (FOR UTF-32), so
when input encoding is unknown one must perform some kind of
detection in
On Saturday, 28 January 2017 at 14:56:03 UTC, rikki cattermole
wrote:
On 29/01/2017 3:51 AM, Nestor wrote:
Hi,
One can get the length of a string easily, however since
strings are
UTF-8, sometimes characters take more than one byte. I would
like to
know then how many bytes does a string
Hi,
One can get the length of a string easily, however since strings
are UTF-8, sometimes characters take more than one byte. I would
like to know then how many bytes does a string take, but this
code didn't work as I expected:
import std.stdio;
void main() {
string mystring1;
string
On Friday, 27 January 2017 at 12:55:55 UTC, Stefan Koch wrote:
You have to compile the library with your app.
or better yet use dub
replace app.d with your app.d and run dub
Thanks. It did compile using dub, though I had a couple of issues
with dub, by the way.
The first occured because I
On Friday, 27 January 2017 at 12:06:33 UTC, Stefan Koch wrote:
On Friday, 27 January 2017 at 12:04:06 UTC, Stefan Koch wrote:
I take it you build without dub ?
Have you specified source/sqlite.d on your compile commandline
?
That was supposed to say.
sqlite-d/source/sqlited.d
Please feel
Hi,
I was trying to use https://github.com/UplinkCoder/sqlite-d
Unfortunately even something as simple as this doesn´t compile
(at least on Windows):
import std.stdio, sqlited;
void main(string[] args) {
string filename = (args.length == 2 ? args[1] : "data.db");
Database db =
On Monday, 23 January 2017 at 01:17:20 UTC, Adam D. Ruppe wrote:
On Monday, 23 January 2017 at 01:12:21 UTC, Nestor wrote:
You mean phobos, or system libraries?
Phobos but mostly the druntime that interfaces with the system.
I see, I was mostly thinking in Android and/or other platforms,
On Saturday, 21 January 2017 at 19:33:27 UTC, Adam D. Ruppe wrote:
On Saturday, 21 January 2017 at 18:38:22 UTC, Nestor wrote:
That would be cool for greater portability.
The hard part in porting to a new platform is rarely the code
generation - gdc and ldc have diverse backends already
Hi friends,
Is there a way to "compile" d code to C, similar to what nim does?
That would be cool for greater portability.
Thank you both!
On Friday, 20 January 2017 at 08:13:08 UTC, drug wrote:
Something like that https://goo.gl/C4nOqw
Because you generate code iterating over AliasSeq you can do
almost everything you need - for example generate
setters/getters.
Interesting site, I wouldn't implemente something like this in a
On Wednesday, 18 January 2017 at 12:52:56 UTC, drug wrote:
I've "solved" the same problem by using AliasSeq to generate
bitfields so that for iterating over bitfields I can iterate
over alias sequence and mixin code. Not very good but it works.
Interesting, could you provide a working
On Wednesday, 18 January 2017 at 01:15:05 UTC, Ali Çehreli wrote:
Not available but it should be possible to parse the produced
code:
import std.bitmanip;
string makeBitFieldPrinter(string fieldImpl) {
return q{
void printBitFields() const {
import std.stdio: writeln;
Hi,
I was just looking at an interesting function from
http://codepad.org/lSDTFd7E :
void printFields(T)(T args) {
auto values = args.tupleof;
size_t max;
size_t temp;
foreach (index, value; values) {
temp = T.tupleof[index].stringof.length;
if (max < temp) max = temp;
}
On Monday, 16 January 2017 at 14:47:23 UTC, Era Scarecrow wrote:
On Sunday, 15 January 2017 at 19:48:04 UTC, Nestor wrote:
I see. So correcting my original doubt:
How could I parse an UTF16LE file line by line (producing a
proper string in each iteration) without loading the entire
file into
On Monday, 16 January 2017 at 06:41:50 UTC, Basile B. wrote:
I remember on Rosetta to have seen this:
module quine;
import std.stdio;
void main(string[] args)
{
write(import("quine.d"));
}
compiles with: dmd path/quine.d -Jpath
Very good! By the way, module name and arguments aren't
Thank you all.
On Sunday, 15 January 2017 at 22:08:47 UTC, pineapple wrote:
On Sunday, 15 January 2017 at 21:37:53 UTC, Nestor wrote:
Any ideas for a shorter version (preferably without using
pointers)?
When compiling with the -main flag, this D program is a quine:
You forgot to include the program... or
On Sunday, 15 January 2017 at 16:29:23 UTC, Daniel Kozák wrote:
This is because byLine does return range, so until you do
something with that it does not cause any harm :)
I see. So correcting my original doubt:
How could I parse an UTF16LE file line by line (producing a
proper string in
I was reading some of the examples of writing a quine with D, but
apparently the language has evolved and they no longer compiled
unchanged.
So I tried to program one by myself using strings and std.stdio,
but the result seems long and redundant:
import std.stdio;void main(){string
On Sunday, 15 January 2017 at 16:57:35 UTC, biozic wrote:
On Sunday, 15 January 2017 at 14:20:04 UTC, Nestor wrote:
On second thought, if a baby was born in march 1 of 1999
(non-leap year), in march 1 of 2000 (leap year) the age would
have been one year plus one day (because of february 29).
On Sunday, 15 January 2017 at 14:48:12 UTC, Nestor wrote:
After some testing I realized that byLine was not the one
failing, but any string manipulation done to the obtained line.
Compile the following example with and without -debug and run
to see what I mean:
import std.stdio, std.string;
On Friday, 6 January 2017 at 11:42:17 UTC, Mike Wey wrote:
On 01/06/2017 11:33 AM, pineapple wrote:
On Friday, 6 January 2017 at 06:24:12 UTC, rumbu wrote:
I'm not sure if this works quite as intended, but I was at
least able
to produce a UTF-16 decode error rather than a UTF-8 decode
error
On Sunday, 15 January 2017 at 14:04:39 UTC, Nestor wrote:
...
For example, take a baby born in february 29 of year 2000 (leap
year). In february 28 of 2001 that baby was one day short to
one year.
Family can make a concession and celebrate birthdays in
february 28 of non-leap years, but
On Sunday, 15 January 2017 at 11:01:28 UTC, biozic wrote:
On Sunday, 15 January 2017 at 08:40:37 UTC, Nestor wrote:
I cleaned up the function a little, but it still feels like a
hack:
uint getAge(uint , uint mm, uint dd) {
import std.datetime;
SysTime t = Clock.currTime;
ubyte
I cleaned up the function a little, but it still feels like a
hack:
uint getAge(uint , uint mm, uint dd) {
import std.datetime;
SysTime t = Clock.currTime;
ubyte correction = 0;
if(
(t.month < mm) ||
( (t.month == mm) && (t.day < dd) )
) correction += 1;
return (t.year -
On Sunday, 15 January 2017 at 07:25:26 UTC, rikki cattermole
wrote:
So I had a go at this and found I struggled looking at "magic"
functions and methods.
Turns out there is a much simpler answer.
int getAge(int , int mm, int dd) {
import std.datetime;
auto t1 =
On Wednesday, 4 January 2017 at 18:48:59 UTC, Daniel Kozák wrote:
Ok, I've done some testing and you are right byLine is broken,
so please fill a bug
A bug? I was under the impression that this function was
*intended* to work only with UTF-8 encoded files.
Hi,
I was just trying to parse a UTF-16LE file using byLine, but
apparently this function doesn't work with anything other than
UTF-8, because I get this error:
"Invalid UTF-8 sequence (at index 1)"
How can I achieve what I want, without loading the entire file
into memory?
Thanks in
I managed to isolate the problem to the following. Program 1
below works (displays unit test failure when run), while program
2 does not.
* Program 1 *
import std.stdio;
unittest
{
assert(false);
}
void main()
{
writeln(Hello D-World!);
}
* Program 2 *
module
Hello everybody, this is my first post on this forum.
I have a question about unit testing a Windows application. I
have slightly modified Visual D's default Windows application
stub to the following:
code
module winmain;
import core.runtime;
import core.sys.windows.windows;
unittest {
59 matches
Mail list logo