On 31.01.15 15:45, RuZzz wrote:
Maybe I need good examples on C++, for this class, because a lot of
examples on C++.
Maybe this can help you:
https://github.com/andersonpd/decimal
On 31.01.15 15:56, zeljkog wrote:
On 31.01.15 15:45, RuZzz wrote:
Maybe I need good examples on C++, for this class, because a lot of
examples on C++.
Maybe this can help you:
https://github.com/andersonpd/decimal
Also
http://code.dlang.org/packages/eris
On 31.01.15 17:04, tcak wrote:
I do not have a big example in the end to show, but is there any way to
put labels into struct definitions?
struct CommunicationMessage{
char[2] signature;
mainData:
int info1;
int info2;
extraData:
ushort checksum;
content:
}
Members of
I tried:
--
import std.stdio, std.algorithm;
auto unique(){
bool[int] c;
return (int a){
if (a in c)
return false;
else{
c[a] = true;
return true;
}
};
}
void main()
{
[1, 5, 5, 2, 1, 5, 6,
On 22.01.15 20:05, Meta wrote:
On Thursday, 22 January 2015 at 19:00:47 UTC, zeljkog wrote:
On 22.01.15 19:26, Meta wrote:
On Thursday, 22 January 2015 at 18:23:00 UTC, Meta wrote:
Whoops, I forgot to make it a template to force CTFE.
You can force CTFE assigning to manifest constant.
enum
On 22.01.15 19:26, Meta wrote:
On Thursday, 22 January 2015 at 18:23:00 UTC, Meta wrote:
Whoops, I forgot to make it a template to force CTFE.
You can force CTFE assigning to manifest constant.
enum t = charRange!...
On 19.12.14 16:25, Steven Schveighoffer wrote:
This is surprising to me. I would expect especially ints to be faster.
In reality, there is no difference between arr ~= args and arr.length +=
args.length, and then copying, it's just how you do the copying. Perhaps
it's the call to memcpy in the
On 19.12.14 23:56, Ali Çehreli wrote:
Can we see the test code please.
Ali
import std.stdio, std.datetime, std.random;
int N = 10_000;
int len = 1000;
int k = 4;
struct S{
int n1, n2;
//~ this(this){
//~ writeln(this(this));
//~ }
}
ref T[] append(T, Args...)(ref T[]
If you wish run this just add:
struct S{
int n1, n2, n3, n4, n5 ...;
}
On 18.12.14 14:50, Steven Schveighoffer wrote:
I wonder how your code compares to this:
void append(T)(ref T[] arr, T[] args...)
{
arr ~= args;
}
This is ~20% slower for ints, but it difference increases for bigger structs.
On 15.12.14 01:00, Nordlöw wrote:
Isn't this algorithm already encoded somewhere in Phobos?
void append(T, Args...)(ref T[] arr, auto ref Args args){
{
static if (args.length == 1)
arr ~= args[0]; // inlined
else{
arr.length += args.length;
foreach(i, e; args)
On 17.12.14 13:30, Tobias Pankrath wrote:
void append(T, Args...)(ref T[] data, Args args)
{
static size_t estimateLength(Args args)
{
size_t result;
foreach(e; args)
static if(hasLength!(typeof(e)))
result += e.length;
else
On 15.12.14 00:16, Nordlöw wrote:
or some other trick?
void append(T, Args...)(ref T[] arr, Args args){
arr.length += args.length;
foreach(i, e; args)
arr[$ - args.length + i] = args[i];
}
void main()
{
int[] arr = [1, 2, 3, 4, 5];
arr.append(3, 10, 14);
writeln(arr);
}
output:
On 15.12.14 01:00, Nordlöw wrote:
Isn't this algorithm already encoded somewhere in Phobos?
I don't know.
import std.stdio, core.thread;
struct Tree{
int val;
Tree[] tree;
}
struct TreeRange{
Tree curtree;
bool empty;
Fiber worker;
this(Tree t){
worker = new Fiber(fiberFunc);
curtree = t;
popFront();
}
void fiberFunc(){
Tree t = curtree;
Fiber.yield();
On 13.12.14 13:01, zeljkog wrote:
void main() {
auto tt = Tree(5, [Tree(7,[Tree(11), Tree(4)]), Tree(10)]);
auto tr1 = TreeRange(tt);
foreach(v; tr1){
writef(%2d, , v);
}
writeln();
for(auto r = TreeRange(tt); !r.empty; r.popFront())
writef(%2d, , r.front);
16 matches
Mail list logo