Re: Convert some ints into a byte array without allocations?

2016-01-16 Thread Yazan D via Digitalmars-d-learn
On Sat, 16 Jan 2016 14:34:54 +, Samson Smith wrote: > I'm trying to make a fast little function that'll give me a random > looking (but deterministic) value from an x,y position on a grid. I'm > just going to run each co-ord that I need through an FNV-1a hash > function as an array of bytes si

Re: Convert some ints into a byte array without allocations?

2016-01-16 Thread Yazan D via Digitalmars-d-learn
On Sat, 16 Jan 2016 14:42:27 +, Yazan D wrote: > > You can do this: > ubyte[] b = (cast(ubyte*) &a)[0 .. int.sizeof]; > > It is casting the pointer to `a` to a ubyte (or byte) pointer and then > taking a slice the size of int. You can also use a union: union Foo { int i; ubyte[4] b; }

Re: Decrease number of front evaluations

2015-08-26 Thread Yazan D via Digitalmars-d-learn
On Wed, 26 Aug 2015 08:27:05 +, FreeSlave wrote: > > Are there ways to fix this? Should I consider writing my own range type > probably? Check http://dlang.org/phobos/std_algorithm_iteration.html#.cache

Re: Trying to compile weather program

2015-08-23 Thread Yazan D via Digitalmars-d-learn
On Sun, 23 Aug 2015 16:00:16 +, Tony wrote: > Thanks for the replies. It compiles OK with just. However, it isn't > linking: > > /usr/bin/ld: cannot find -lcurl > > > I do have some versions of libcurl on my system: > > /usr/lib/x86_64-linux-gnu/libcurl.so.3 > /usr/lib/x86_64-linux-gnu/lib

Re: Measuring Execution time

2015-07-24 Thread Yazan D via Digitalmars-d-learn
There is also http://linux.die.net/man/2/sched_setaffinity if you want to do it programmatically.

Re: Measuring Execution time

2015-07-24 Thread Yazan D via Digitalmars-d-learn
On Thu, 23 Jul 2015 16:43:01 +, Clayton wrote: > On Wednesday, 22 July 2015 at 09:32:15 UTC, John Colvin wrote: >> On Wednesday, 22 July 2015 at 09:23:36 UTC, Clayton wrote: >>> [...] >> >> The normal way of doing this would be using std.datetime.StopWatch: >> >> StopWatch sw; >> sw.st