On Friday, 15 July 2016 at 04:38:03 UTC, Basile B. wrote:
two obvious:
- recursive template.
- staticIota in a foreach. (aliasSeqOf!(iota(1, T.length))
even better:
template sameType(T...)
{
import std.meta;
static if (!T.length)
enum sameType = false;
else
enum
On Friday, 15 July 2016 at 04:31:08 UTC, Devin Hill wrote:
Thanks, that way of doing it does work. I guess that means
there's no easy way to make sure all T are the same type
without a template constraint?
Yes, immediatly, now, I think that a contraint has to be used.
But you have several
On Friday, 15 July 2016 at 04:08:19 UTC, Basile B. wrote:
With D style variadics it works, you can build the array from
the list and have a static array:
=
void foo(T...)(T t)
{
T[0][T.length] tt = [t]; // T[0] is the type
writeln(tt); // [1,2,3]
static
On Friday, 15 July 2016 at 03:43:49 UTC, Devin Hill wrote:
Hi everyone,
I have a struct template which takes an integer n, and then has
a constructor taking that many arguments of type long, which
looks like:
struct Struct(int n) {
this(long[n] nums...) { /* stuff */ }
}
This works and
Hi everyone,
I have a struct template which takes an integer n, and then has a
constructor taking that many arguments of type long, which looks
like:
struct Struct(int n) {
this(long[n] nums...) { /* stuff */ }
}
This works and lets me change n for each instantiation, but I
wanted to
On Thursday, 14 July 2016 at 08:28:56 UTC, Jacob Carlborg wrote:
On 2016-07-14 07:18, dan wrote:
I'm writing a small program (compiled with gdc on xubuntu
16.04).
I would like it to remember a little data (a few kilobytes
maybe).
.
My main concern is minimizing program complexity.
How can I create a new type NT from type T that such that NT is
compatible with T when reduced to the size of T, but has size n?
Another way to see it is that I would like to construct a type at
compile time that has the same layout as another type but padded
exactly by n - T.sizeof bytes. It
On Thursday, 14 July 2016 at 19:48:38 UTC, ag0aep6g wrote:
Make F an alias parameter:
struct Neurons_layer(T = float, size_t neurons_num = 0, alias F
= Sigmoid)
if(isFloatingPoint!T && is(typeof(F!T.Function)))
{
...
private:
alias Function = F!T.Function;
}
unittest
{
On Thursday, 14 July 2016 at 19:48:20 UTC, Lodovico Giaretta
wrote:
You don't need Sigmoid!float at all. This will work:
Neurons_layer!(float, 5) nf;
as you provided a default value for the third argument.
Yes, default init is present, but double, real types are desirable
On Thursday, 14 July 2016 at 19:28:23 UTC, Andrey wrote:
On Thursday, 14 July 2016 at 19:27:14 UTC, Andrey wrote:
[...]
struct Sigmoid(T)
{
[...]
}
struct Neurons_layer(T = float, size_t neurons_num = 0, F =
Sigmoid!T)
if(isFloatingPoint!T && is(typeof(F.Function)))
{
[...]
On 7/14/16 3:28 PM, Andrey wrote:
On Thursday, 14 July 2016 at 19:27:14 UTC, Andrey wrote:
struct Neurons_layer(T = float, size_t neurons_num = 0, F = Sigmoid!T)
if(isFloatingPoint!T && is(typeof(F.Function)))
{
private:
static if(neurons_num > 0)
T[neurons_num]
On Thursday, 14 July 2016 at 19:28:23 UTC, Andrey wrote:
On Thursday, 14 July 2016 at 19:27:14 UTC, Andrey wrote:
Hi guys!
Help a newbie please.
Playing with D and trying to understand some features.
Here is my try to carry out my code from C++ project to D
struct Sigmoid(T)
{
const T
On Thursday, 14 July 2016 at 19:27:14 UTC, Andrey wrote:
Hi guys!
Help a newbie please.
Playing with D and trying to understand some features.
Here is my try to carry out my code from C++ project to D
struct Sigmoid(T)
{
const T Function(T value)
{
...
}
const T
Hi guys!
Help a newbie please.
Playing with D and trying to understand some features.
Here is my try to carry out my code from C++ project to D
struct Sigmoid(T)
{
const T Function(T value)
{
...
}
const T DerivateFunction(const T value)
{
...
}
}
struct Neurons_layer(T =
On 7/14/16 5:56 AM, Miguel L wrote:
On Thursday, 14 July 2016 at 09:12:50 UTC, Jonathan M Davis wrote:
So, whether you should be using Appender or assumeSafeAppend or
neither depends entirely on what you're doing. However, in general,
simply appending to dynamic arrays does not result in many
On Wednesday, 13 July 2016 at 22:30:51 UTC, Adam Sansier wrote:
Um, no, I revived it so that people searching for answers
wouldn't be led astray by idiots who pretend to know everything.
My word is not COM specification of course, there's the official
documentation and tons of books about
On 7/14/16 7:03 AM, Sahil wrote:
On Thursday, 14 July 2016 at 10:51:33 UTC, Nicholas Wilson wrote:
On Thursday, 14 July 2016 at 10:43:12 UTC, Sahil wrote:
This is with reference to documentation about use of array in D
(https://dlang.org/spec/arrays.html#array-setting).
easily. The function
On Wednesday, 13 July 2016 at 22:42:36 UTC, Adam Sansier wrote:
On Wednesday, 13 July 2016 at 21:27:16 UTC, Lodovico Giaretta
wrote:
At the end, all memory comes from one of these: GC heap,
malloc, mmap, sbrk. All other allocators build on top of these
(or on top of user supplied buffers,
On Thursday, 14 July 2016 at 09:29:10 UTC, Jonathan M Davis wrote:
On Thursday, July 14, 2016 07:20:46 cym13 via
Digitalmars-d-learn wrote:
[...]
Whatever the profiler is telling you, it's clearly not actually
telling you whether an allocation took place, and that's easy
to test. For
On Thursday, 14 July 2016 at 06:23:15 UTC, Gorge Jingale wrote:
I think that the assignment in the first case is not assigning
the reference returned by auto ref GetValue().
`ref` in D is shallow, it only applies to the thing it is
specifically on and is lost across assignments. Once you
Hi!
I've stumbled across the following problem: when I raise an
exception from a (statically linked) library that was compiled
with -fPIC, I get a segmentation fault. Example:
-- libfoo/dub.json
{
"name" : "foo",
"description" : "Exception raising lib",
"dflags" : [
On Thursday, 14 July 2016 at 11:01:20 UTC, Nicholas Wilson wrote:
On Thursday, 14 July 2016 at 10:51:33 UTC, Nicholas Wilson
wrote:
I should explain this a bit more if you are totally new to D.
although filter looks like a method for an array type it is not
it is a function.
in D function
On Thursday, July 14, 2016 09:56:02 Miguel L via Digitalmars-d-learn wrote:
> Thank you Jonathan, that really cleared up a lot of things, I
> read the article. But I still have this doubt: is
> assumeSafeAppend() changing a property of the array as "this
> array is never going to be referenced by
On Thursday, 14 July 2016 at 10:51:33 UTC, Nicholas Wilson wrote:
On Thursday, 14 July 2016 at 10:43:12 UTC, Sahil wrote:
This is with reference to documentation about use of array in
D (https://dlang.org/spec/arrays.html#array-setting).
easily. The function you are looking for is called
On Thursday, 14 July 2016 at 10:51:33 UTC, Nicholas Wilson wrote:
On Thursday, 14 July 2016 at 10:43:12 UTC, Sahil wrote:
(I am totally new to D)
easily. The function you are looking for is called 'filter'
import std.algorithm;
import std.array;
int[] a = [ 4,5,8,1,3,2,9,10];
auto b =
On Thursday, 14 July 2016 at 10:43:12 UTC, Sahil wrote:
This is with reference to documentation about use of array in D
(https://dlang.org/spec/arrays.html#array-setting).
In languages tailor-made for data mining, like R, a subset of
an array (not necessarily contiguous values) can be
This is with reference to documentation about use of array in D
(https://dlang.org/spec/arrays.html#array-setting).
In languages tailor-made for data mining, like R, a subset of an
array (not necessarily contiguous values) can be extracted as
shown below:
vec //a vector or array in R
On Wednesday, 13 July 2016 at 21:27:29 UTC, Adam Sansier wrote:
Yes! your right, If you were only around to tell me that in the
first place! ;) Now we know. Again, as I said before, the
problem is informational.
We know it only after you posted links to threads with relevant
info. You knew
On Thursday, 14 July 2016 at 00:33:50 UTC, ethgeh wrote:
On Wednesday, 13 July 2016 at 19:41:53 UTC, dom wrote:
how can i run my unittests for a dynamic library? some weird
conflict is reported between main functions, my project doesnt
contain any main function.
[...]
try to put this
On Thursday, 14 July 2016 at 09:12:50 UTC, Jonathan M Davis wrote:
So, whether you should be using Appender or assumeSafeAppend or
neither depends entirely on what you're doing. However, in
general, simply appending to dynamic arrays does not result in
many reallocations (just like it doesn't
On Thursday, 14 July 2016 at 06:23:15 UTC, Gorge Jingale wrote:
I think that the assignment in the first case is not assigning
the reference returned by auto ref GetValue().
Yep. There's no such thing as C++ `auto& val = GetValue()` in D.
You'd have to use a pointer instead: `auto pVal = ()`.
On Thursday, July 14, 2016 07:20:46 cym13 via Digitalmars-d-learn wrote:
> As one can see there seem to be absolutely no difference in
> allocations wether we reserve or not. I've ran more experiences,
> reserving way less or more than I appened to no avail:
> allocations seem to just ignore it.
>
On Thursday, July 14, 2016 07:07:52 Miguel L via Digitalmars-d-learn wrote:
> Ok, i have read about Appender and assumeSafeAppend(), but i am
> still a bit confused.
> What i have understood is: dynamic arrays are (almost) always
> reallocating when appending to them except assumeSafeAppend() is
>
On 2016-07-14 07:18, dan wrote:
I'm writing a small program (compiled with gdc on xubuntu 16.04).
I would like it to remember a little data (a few kilobytes maybe).
It looks like d comes with standard support for both sqlite3 and json
--- is there any particular reason to prefer one over the
Does changing the capacity of dynamic arrays actually do anything
with respect to memory allocation? I have the following data with
DMD 2.071.1
// With dmd -profile=gc
void main() {
import std.stdio;
int[] arr = [1, 1, 1];
arr.reserve(512);
foreach (i ; 0..10)
arr ~=
On Wednesday, 13 July 2016 at 17:19:09 UTC, Steven Schveighoffer
wrote:
On 7/13/16 8:41 AM, Lodovico Giaretta wrote:
On Wednesday, 13 July 2016 at 12:37:26 UTC, Miguel L wrote:
I tried Appender, but for some reason garbage collector still
seems to
be running every few iterations.
I will try
On 14/07/2016 6:23 PM, Gorge Jingale wrote:
I'm pretty confused why the following code doesn't work as expected.
GetValue is a struct.
auto value = GetValue();
memcpy(, , Val.sizeof);
But if I plug in value direct to memset it works!!
memcpy((), , Val.sizeof);
GetValue returns memory
I'm pretty confused why the following code doesn't work as
expected.
GetValue is a struct.
auto value = GetValue();
memcpy(, , Val.sizeof);
But if I plug in value direct to memset it works!!
memcpy((), , Val.sizeof);
GetValue returns memory to stick a value in and the memcpy is
38 matches
Mail list logo