How to organize a project with local scripts in subdirectories using dub?

2019-12-11 Thread Pavel Shkadzko via Digitalmars-d-learn
I have the following project structure. my_proj/ script_1/runme_1.d script_2/runme_2.d evaluator.d The project has a library dependency: "dependencies": { "mir": "~>3.2.0", }, The "evaluator.d" script contains some general functions that convert dataset and pass it to

Re: How to organize a project with local scripts in subdirectories using dub?

2019-12-11 Thread Pavel Shkadzko via Digitalmars-d-learn
On Wednesday, 11 December 2019 at 16:06:30 UTC, drug wrote: Add to dub.json: "targetType": "executable" and it will build executable. Or rename evaluator.d to app.d It is confused that there is no app.d so it thinks that you build a library. I added "targetType" and now everything works

Re: How to organize a project with local scripts in subdirectories using dub?

2019-12-11 Thread Pavel Shkadzko via Digitalmars-d-learn
On Wednesday, 11 December 2019 at 13:00:32 UTC, drug wrote: I would restructure your folders this way: my_proj/ source/ script_1/runme_1.d script_2/runme_2.d evaluator.d then using `dub --compiler=ldc2` It works like this, yes. However, by default it builds a

How to generate ddoc html?

2020-01-29 Thread Pavel Shkadzko via Digitalmars-d-learn
I've been skimming through https://dlang.org/spec/ddoc.html in order to understand how can one use ddoc to generate nice htmls. I tend to use markdown to log some daily work or copy down code examples. For learning purposes I wanted to try ddoc for this but could not find any information on

Re: books for learning D

2020-01-13 Thread Pavel Shkadzko via Digitalmars-d-learn
On Monday, 13 January 2020 at 10:28:48 UTC, mark wrote: I'm just starting out learning D. Andrei Alexandrescu's "The D Programming Language" is 10 years old, so is it still worth getting? (I don't know how much D has changed in 10 years.) Start with "Programming in D" by Ali:

Re: How to sort 2D Slice along 0 axis in mir.ndslice ?

2020-03-11 Thread Pavel Shkadzko via Digitalmars-d-learn
On Wednesday, 11 March 2020 at 06:12:55 UTC, 9il wrote: On Wednesday, 11 March 2020 at 00:24:13 UTC, jmh530 wrote: [...] Almost the same, just fixed import for `each` and a bit polished /+dub.sdl: dependency "mir-algorithm" version="~>3.7.18" +/ import mir.ndslice; import

Re: How does a free list work?

2020-05-12 Thread Pavel Shkadzko via Digitalmars-d-learn
On Saturday, 9 May 2020 at 22:48:46 UTC, Simen Kjærås wrote: On Saturday, 9 May 2020 at 19:54:44 UTC, Pavel Shkadzko wrote: [...] The GC keeps a list of roots - that is, objects that are known to be active and should not be collected. The static freelist is one of those - since it's static

How does a free list work?

2020-05-09 Thread Pavel Shkadzko via Digitalmars-d-learn
I have been reading about memory management in D on https://wiki.dlang.org/Memory_Management and found an example of a free list (pattern?): "Free lists are a great way to accelerate access to a frequently allocated and discarded type.". Here is the example of free list:

Re: Compilation error: undefined reference to 'cblas_dgemv' / 'cblas_dger' / 'cblas_dgemm'

2020-03-10 Thread Pavel Shkadzko via Digitalmars-d-learn
On Monday, 13 January 2020 at 20:47:07 UTC, p.shkadzko wrote: On Sunday, 12 January 2020 at 13:07:33 UTC, dnsmt wrote: On Saturday, 11 January 2020 at 16:45:22 UTC, p.shkadzko wrote: I am trying to run example code from https://tour.dlang.org/tour/en/dub/lubeck ... This is Linux Manjaro

How to flatten N-dimensional array?

2020-05-23 Thread Pavel Shkadzko via Digitalmars-d-learn
I have tried to implement a simple flatten function for multidimensional arrays with recursive templates but got stuck. Then I googled a little and stumped into complex https://rosettacode.org/wiki/Flatten_a_list#D implementation which requires your arrays to be either TreeList or Algebraic.

Re: How to flatten N-dimensional array?

2020-05-24 Thread Pavel Shkadzko via Digitalmars-d-learn
On Saturday, 23 May 2020 at 19:59:30 UTC, Ali Çehreli wrote: On 5/23/20 11:15 AM, Pavel Shkadzko wrote:> I have tried to implement a simple flatten function for multidimensional [...] Thank you, I was lacking practical examples for templates with "if" constructs, ehh.

Re: How to flatten N-dimensional array?

2020-05-24 Thread Pavel Shkadzko via Digitalmars-d-learn
On Sunday, 24 May 2020 at 11:21:00 UTC, 9il wrote: On Saturday, 23 May 2020 at 18:15:32 UTC, Pavel Shkadzko wrote: [...] If the common nd-array isn't jugged (a parallelotop), you can use fuse function. -- /+dub.sdl: dependency "mir-algorithm" version="~>3.8.12" +/ import std.stdio:

Mir Slice.shape is not consistent with the actual array shape

2020-05-24 Thread Pavel Shkadzko via Digitalmars-d-learn
I am confused by the return value of Mir shape. Consider the following example. /// import std.stdio; import std.conv; import std.array: array; import std.range: chunks; import mir.ndslice; int[] getShape(T : int)(T obj,

Re: Mir Slice.shape is not consistent with the actual array shape

2020-05-24 Thread Pavel Shkadzko via Digitalmars-d-learn
On Sunday, 24 May 2020 at 14:21:26 UTC, Pavel Shkadzko wrote: On Sunday, 24 May 2020 at 14:17:33 UTC, Pavel Shkadzko wrote: I am confused by the return value of Mir shape. Consider the following example. [...] Sorry for the typo. It should be "auto arrSlice = a.sliced;" And another typo

Re: Mir Slice.shape is not consistent with the actual array shape

2020-05-24 Thread Pavel Shkadzko via Digitalmars-d-learn
On Sunday, 24 May 2020 at 14:17:33 UTC, Pavel Shkadzko wrote: I am confused by the return value of Mir shape. Consider the following example. [...] Sorry for the typo. It should be "auto arrSlice = a.sliced;"

Re: Mir Slice.shape is not consistent with the actual array shape

2020-05-24 Thread Pavel Shkadzko via Digitalmars-d-learn
On Sunday, 24 May 2020 at 14:35:33 UTC, jmh530 wrote: On Sunday, 24 May 2020 at 14:21:26 UTC, Pavel Shkadzko wrote: [snip] Sorry for the typo. It should be "auto arrSlice = a.sliced;" Try using fuse /+dub.sdl: dependency "mir-algorithm" version="*" +/ import std.stdio; import std.conv;

Re: Mir Slice.shape is not consistent with the actual array shape

2020-05-24 Thread Pavel Shkadzko via Digitalmars-d-learn
On Sunday, 24 May 2020 at 15:24:14 UTC, 9il wrote: On Sunday, 24 May 2020 at 14:17:33 UTC, Pavel Shkadzko wrote: [...] BTW, the code example above doesn't compiles. OT: Instead of [...] you can generate the same common D array using Mir: auto a = [2, 2, 4].iota!int(1).ndarray;