Re: Using std.random.uniform as a range

2015-08-08 Thread drug via Digitalmars-d-learn
08.08.2015 01:34, Ali Çehreli пишет: On 08/07/2015 06:59 AM, drug wrote: What is the best way to create range from uniform() function (in other words create a generator based on some function, returning, say, scalar, not range)? I did http://dpaste.dzfl.pl/53e3d9255cd7 but I'm not sure it's the

Re: Template-Parameterized Variadic isInstaceOf

2015-08-08 Thread Nordlöw
On Friday, 7 August 2015 at 11:45:22 UTC, Nordlöw wrote: To implement a new trait isSortedRange(R, pred) needed for SortedRange specializations I need a variant of I've put all my progress into https://github.com/D-Programming-Language/phobos/pull/3534

Re: Using std.random.uniform as a range

2015-08-08 Thread via Digitalmars-d-learn
On Friday, 7 August 2015 at 22:34:40 UTC, Ali Çehreli wrote: There is an undocumented (why?) Generator struct and generate() functin in std.range: It's new in 2.068, that's why it's missing in the current docs. It's already in the prerelease docs: http://dlang.org/phobos-prerelease/std_range

Re: How to run opengl tutorials

2015-08-08 Thread QAston via Digitalmars-d-learn
On Sunday, 2 August 2015 at 10:04:54 UTC, nikolai wrote: Yes, I was so excited about Dlang that i forgot to paste the error: Here's the link to imagescreen http://prntscr.com/7zwe6h Can't help you with your problem, but I have another tip: Shift-right-click inside a dir-> open cmd window here

Re: Concurrency Confusion

2015-08-08 Thread Chris via Digitalmars-d-learn
On Saturday, 8 August 2015 at 00:39:57 UTC, 岩倉 澪 wrote: On Friday, 7 August 2015 at 22:13:35 UTC, 岩倉 澪 wrote: "message" is local to the delegate that receiveTimeout takes. I want to use "message" outside of the delegate in the receiving thread. However, if you send an immutable value from the

Dynamic array and foreach loop

2015-08-08 Thread Binarydepth via Digitalmars-d-learn
I'm writing a program that rotates numbers then asks the user if a new set of numbers should be rotated. I'm having trouble using a Foreach loop to fill a dynamic array with the elements to be rotated. Here's my code, I add a TAB when a loop is inside a loop and and do that too to the stateme

Re: Dynamic array and foreach loop

2015-08-08 Thread Binarydepth via Digitalmars-d-learn
Here's what happens : How many elements need to be used? 5 Input the element : 1 1 Input the element : 1 2 Input the element : 1 3 Input the element : 1 4 Input the element : 1 5 How many positions do you wish to rotate ? 3 The original patter is : 5 0 0 0 0 The final is : 0 0 0 5 0 Do you want t

Re: Dynamic array and foreach loop

2015-08-08 Thread DarthCthulhu via Digitalmars-d-learn
On Saturday, 8 August 2015 at 15:57:15 UTC, Binarydepth wrote: Here's what happens : How many elements need to be used? 5 Input the element : 1 1 Input the element : 1 2 Input the element : 1 3 Input the element : 1 4 Input the element : 1 5 How many positions do you wish to rotate ? 3 The origi

Re: Dynamic array and foreach loop

2015-08-08 Thread Binarydepth via Digitalmars-d-learn
On Saturday, 8 August 2015 at 17:19:08 UTC, DarthCthulhu wrote: You can fix it like the following: foreach(num, element; liaOrig) {//Data input loop writefln("num: %s current element: %s liaOrig.length: %s", num, element, liaOrig.length); write("In

Re: assigning a struct object to an array

2015-08-08 Thread Reflexive via Digitalmars-d-learn
On Friday, 7 August 2015 at 23:01:33 UTC, Ali Çehreli wrote: Thank you very much for the kind words. Which format are you using? It is good to hear that it is acceptable as an ebook, as I've always targetted HTML and then PDF for the print version (which should be purchasable "any day now"

Re: Dynamic array and foreach loop

2015-08-08 Thread Binarydepth via Digitalmars-d-learn
On Saturday, 8 August 2015 at 18:24:48 UTC, Binarydepth wrote: On Saturday, 8 August 2015 at 17:19:08 UTC, DarthCthulhu wrote: Now 'num' is just an iterative number starting from 0 (the .init value of an int), while the actual element value is stored in 'element'. I added the writefln() stat

file rawRead and rawWrite in chunks example

2015-08-08 Thread Jay Norwood via Digitalmars-d-learn
I'm playing around with the range based operations and with raw file io. I couldn't figure out a way to get rid of the outer foreach loops. Nice execution time of 537 msec for this, which creates and reads back a file of about 160MB (20_000_000 doubles). import std.algorithm; import std.st

Re: Dynamic array and foreach loop

2015-08-08 Thread Jay Norwood via Digitalmars-d-learn
On Saturday, 8 August 2015 at 18:28:25 UTC, Binarydepth wrote: This is the new code : foreach(num; 0..liEle) {//Data input loop write("Input the element : ", num+1, " "); readf(" %d", &liaOrig[num]); } Even better : foreach(num; 0..liaOrig.len

Re: file rawRead and rawWrite in chunks example

2015-08-08 Thread Ali Çehreli via Digitalmars-d-learn
On 08/08/2015 04:11 PM, Jay Norwood wrote: I'm playing around with the range based operations and with raw file io. I couldn't figure out a way to get rid of the outer foreach loops. When the body of the foreach loop performs something, then std.algorithm.each can be useful: import std.algo

Re: file rawRead and rawWrite in chunks example

2015-08-08 Thread Jay Norwood via Digitalmars-d-learn
On Sunday, 9 August 2015 at 00:50:16 UTC, Ali Çehreli wrote: { auto f = File(fn,"wb"); iota(10.5, 20_000_010.5, 1.0) .chunks(100) .each!(a => f.rawWrite(a.array)); } Ali Thanks. There are many examples of numeric to string data output in t

Specify variable type for range of associative arrays.

2015-08-08 Thread Christopher Davies via Digitalmars-d-learn
I'm just learning D. Something I often do in C# is have an IEnumerable (Range) of some type that is then conditionally filtered. It looks like this: IEnumerable> foo = bar; if (baz) { foo = foo.Where(d => d["key"] == value); } I'm trying to do the same in D. Here's what I want to do: Ran

Re: file rawRead and rawWrite in chunks example

2015-08-08 Thread Jay Norwood via Digitalmars-d-learn
On Sunday, 9 August 2015 at 00:50:16 UTC, Ali Çehreli wrote: // NOTE: No need to tell rawRead the type as double iota(10, 20_000_000 + 10, n) .each!(a => f.rawRead(dbv)); } Ali Your f.rawRead(dbv) form compiles, but f.rawRead!(dbv) results in an error msg in c

Re: file rawRead and rawWrite in chunks example

2015-08-08 Thread Ali Çehreli via Digitalmars-d-learn
On 08/08/2015 07:07 PM, Jay Norwood wrote: > On Sunday, 9 August 2015 at 00:50:16 UTC, Ali Çehreli wrote: >> // NOTE: No need to tell rawRead the type as double >> iota(10, 20_000_000 + 10, n) >> .each!(a => f.rawRead(dbv)); >> } >> >> Ali > > Your f.rawRead(dbv) f