Re: Help with Ranges

2020-07-27 Thread Charles via Digitalmars-d-learn
On Monday, 27 July 2020 at 18:15:26 UTC, Steven Schveighoffer wrote: On 7/27/20 1:10 PM, Charles wrote: [...] Let's talk about a concrete example, so you can see why: int[] arr = [21, 83, 45, 60]; [...] I had very incorrect model of how ranges function, and after reading your post along

Re: Help with Ranges

2020-07-27 Thread Charles via Digitalmars-d-learn
On Monday, 27 July 2020 at 16:52:51 UTC, H. S. Teoh wrote: On Sun, Jul 26, 2020 at 07:10:41AM +, Charles via Digitalmars-d-learn wrote: Suppose I have the following line of code where arr is an array, doSomething is some predicate that does a lot of processing on each element, sort must

Re: Help with Ranges

2020-07-27 Thread Charles via Digitalmars-d-learn
On Sunday, 26 July 2020 at 14:56:35 UTC, Steven Schveighoffer wrote: A map that returns an lvalue would be sortable, but you would be sorting the processed elements, and probably not the original elements. Indeed, but that's what I want: sort the process elements. Otherwise, I'd place sort

Help with Ranges

2020-07-26 Thread Charles via Digitalmars-d-learn
Suppose I have the following line of code where arr is an array, doSomething is some predicate that does a lot of processing on each element, sort must come after the mapping, and there are more operations done to the range after sort: arr.map!doSomething.sort. ...; Sort fails to instantiate

Re: Setup help?

2019-02-06 Thread Charles via Digitalmars-d-learn
On Thursday, 7 February 2019 at 02:55:15 UTC, evilrat wrote: You need C++ tools from Microsoft to debug D code, don't mind the name, its debugger works for any (compatible formats) native code. Then add C++ Windows debug configuration and set your paths. Done. You can debug now. (Though it

Setup help?

2019-02-06 Thread Charles via Digitalmars-d-learn
Does anyone know of a video that shows setting up vscode (or another editor with debugging support)? I always feel like I miss a step when I decide to try D out again, and it never ends well. I don't use C++, and I do use Windows, which has me wondering if I'm just missing some

Re: In language tooling

2016-03-04 Thread Charles via Digitalmars-d-learn
On Wednesday, 2 March 2016 at 03:41:57 UTC, sigod wrote: Very interesting. I wonder what Walter would say about it. Yeah, I'm curious what others' thoughts on it are for sure.

In language tooling

2016-03-02 Thread Charles via Digitalmars-d-learn
Watched a video on Jonathan Blow's language that he's developing, and he has a pretty neat idea of having tools being part of the language. Looking at the first 15 minutes(https://www.youtube.com/watch?v=OHZwYYW9koI) or so of the video, is this something that could be accomplished in D with

Re: Is this a good singleton?

2016-02-13 Thread Charles via Digitalmars-d-learn
On Saturday, 13 February 2016 at 19:32:33 UTC, Ali Çehreli wrote: David Simcha's DConf 2013 presentation has a singleton implementation at 27:55: https://www.youtube.com/watch?v=yMNMV9JlkcQ Ali Neat video! Watched the singleton section to end up watching the rest of the video. Anything

Re: Questions about vibe.d

2016-02-12 Thread Charles via Digitalmars-d-learn
On Friday, 12 February 2016 at 12:31:57 UTC, Guillaume Piolat wrote: 1. Can vibe.d handle HTTPS connections? 2. Can vibe.d "rewrite" HTTP connections to HTTPS? 3. Can vibe.d be put behind a nginx reverse proxy? 4. Can vibe.d send mails? 1. Yes. Example:

Re: Questions about vibe.d

2016-02-12 Thread Charles via Digitalmars-d-learn
On Friday, 12 February 2016 at 14:36:18 UTC, Ola Fosheim Grøstad wrote: On Friday, 12 February 2016 at 12:31:57 UTC, Guillaume Piolat wrote: Sorry if these questions are a bit basic, the implied subtext is "and does it work well?". Just in case you didn't know, browsers now support HTTP/2

algorithm's .filter!() by range key

2016-02-09 Thread Charles via Digitalmars-d-learn
This seems to be true of any range function really... is there a way to access the key within my range? Example of what I want to do: auto x = [1,2,3,4,5]; x.filter( x_key % 2 == 1 ).sum(); // sum odd elements in array

Re: algorithm's .filter!() by range key

2016-02-09 Thread Charles via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 20:44:34 UTC, cym13 wrote: On Tuesday, 9 February 2016 at 20:40:44 UTC, Charles wrote: This seems to be true of any range function really... is there a way to access the key within my range? Example of what I want to do: auto x = [1,2,3,4,5]; x.filter( x_key %

Re: algorithm's .filter!() by range key

2016-02-09 Thread Charles via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 20:48:01 UTC, Steven Schveighoffer wrote: On 2/9/16 3:40 PM, Charles wrote: This seems to be true of any range function really... is there a way to access the key within my range? Example of what I want to do: auto x = [1,2,3,4,5]; x.filter( x_key % 2 == 1

Re: Build utf.d with MS-COFF failed

2015-11-20 Thread Charles via Digitalmars-d-learn
On Friday, 20 November 2015 at 21:27:12 UTC, Pierre wrote: Hello, I can't build my project with MS-COFF option. I'm using DMD 2.069. I got this error : utf.d(1109) : invalid UTF-8 sequence (at index 1) I used these options with visual D: Compiler : DMD D-Version : D2 Output Type

Am I using std.encoding correctly?

2015-11-14 Thread Charles via Digitalmars-d-learn
I have some binary files that I'm reading. At compile time it's unknown what types I'm reading, and if they're strings, how it's encoded. I'm doing something like this: Variant value; switch(type) { ... case Type.STRING: value = cast(dchar[])[];

Re: question about using std.bitmanip.read

2015-11-06 Thread Charles via Digitalmars-d-learn
On Saturday, 7 November 2015 at 04:25:00 UTC, Mike Parker wrote: Missed this in my previous reply. No problem. I appreciate you taking the time to help me either way :)

Re: question about using std.bitmanip.read

2015-11-06 Thread Charles via Digitalmars-d-learn
On Saturday, 7 November 2015 at 03:53:14 UTC, Nicholas Wilson wrote: On Saturday, 7 November 2015 at 03:19:44 UTC, Charles wrote: Hi guys, It's me again... still having some issues pop up getting started, but I remain hopeful I'll stop needing to ask so many questions soon. I'm trying to

question about using std.bitmanip.read

2015-11-06 Thread Charles via Digitalmars-d-learn
Hi guys, It's me again... still having some issues pop up getting started, but I remain hopeful I'll stop needing to ask so many questions soon. I'm trying to use std.bitmanip.read; however, am having some issues using it. For basic testing I'm just trying to use:

Re: Unittest in a library

2015-11-06 Thread Charles via Digitalmars-d-learn
On Friday, 6 November 2015 at 04:34:28 UTC, TheFlyingFiddle wrote: On Friday, 6 November 2015 at 03:59:07 UTC, Charles wrote: Is it possible to have unittest blocks if I'm compiling a library? I've tried having this: test.d: class Classy { unittest { assert(0, "failed test"); }

Unittest in a library

2015-11-05 Thread Charles via Digitalmars-d-learn
Is it possible to have unittest blocks if I'm compiling a library? I've tried having this: test.d: class Classy { unittest { assert(0, "failed test"); } } and then build it with `dmd test.d -lib -unittest` and it doesn't fail the unittest.

Re: ODBC Library?

2015-10-31 Thread Charles via Digitalmars-d-learn
On Monday, 10 November 2014 at 20:37:51 UTC, Charles wrote: For anyone in the future: I needed odbc32.lib, so I created the following odbc32.def and used implib. Thanks me. My computer I was using recently died, and ran into this problem again when getting everything set up. Is there any

What's the "right" way to do openmp-style parallelism?

2015-09-06 Thread Charles via Digitalmars-d-learn
Friends, I have a program that would be pretty easy to parallelize with an openmp pragra in C. I'd like to avoid the performance cost of using message passing, and the shared qualifier seems like it's enforcing guarantees I don't need. Essentially, I have x = float[imax][jmax]; //x is about

Re: Win32 bindings

2015-03-31 Thread Charles via Digitalmars-d-learn
http://www.dsource.org/projects/bindings/wiki/WindowsApi Thanks for this! I guess my brain was wrong thinking it'd be in http://code.dlang.org if it was still being maintained. For some functions, you'll need import libraries. You can get them from the same project as in the above link,

Win32 bindings

2015-03-31 Thread Charles via Digitalmars-d-learn
Hi guys, What is the best (and/or official) source for win32 bindings? I know there's this github project: https://github.com/AndrejMitrovic/DWinProgramming; however, it hasn't been touched in about 2 years. It's currently linked on the wiki (http://wiki.dlang.org/D_for_Win32). I'm also

Re: curl password issue

2015-02-23 Thread Charles via Digitalmars-d-learn
On Tuesday, 24 February 2015 at 00:20:45 UTC, Martin Nowak wrote: On Monday, 23 February 2015 at 16:10:42 UTC, Andre wrote: Curl has some issues with passwords containing special characters like the hash key (#). I don't found any reference for this issue in curl and the D wrapper hardly

Re: vibe-d basic build errors

2015-02-22 Thread Charles via Digitalmars-d-learn
On Friday, 20 February 2015 at 14:36:47 UTC, MartinNowak wrote: On Friday, 20 February 2015 at 04:48:09 UTC, Charles wrote: They're installer versions, dub is 0.9.22 Nov 22 I want to say, and DMD is 2.066.1 Same ones I tried. With --force dmd seems to fail but there is not output. Can you

Re: vibe-d basic build errors

2015-02-19 Thread Charles via Digitalmars-d-learn
On Friday, 20 February 2015 at 02:55:32 UTC, MartinNowak wrote: On Friday, 20 February 2015 at 02:50:05 UTC, Charles wrote: Pastebin of dub --vverbose: http://pastebin.com/4BcHJM74 Target vibe-d 0.7.22 is up to date. Use --force to rebuild. Have you tried the --force switch to rebuild

Re: vibe-d basic build errors

2015-02-19 Thread Charles via Digitalmars-d-learn
On Friday, 20 February 2015 at 04:13:08 UTC, MartinNowak wrote: On Friday, 20 February 2015 at 04:00:21 UTC, Charles wrote: Yes, I have. Here's a pastebin with --force --vverbose: http://pastebin.com/qZEKUN46 Just tried the dub init web vibe.d cd web dub thing, works for me. So the most

vibe-d basic build errors

2015-02-19 Thread Charles via Digitalmars-d-learn
Hi, I'm trying to follow the instructions for vibe-d with: dub init web vibe.d cd web dub and then add the line subConfigurations: {vibe-d: win32} to the dub.json file. This however is producing errors during linking. Could I get a hand? Pastebin of dub --vverbose:

Re: Issue with template function

2015-02-07 Thread Charles via Digitalmars-d-learn
On Friday, 6 February 2015 at 17:40:31 UTC, ketmar wrote: On Fri, 06 Feb 2015 17:09:28 +, Charles wrote: readString(toBytes!string(test),0,4).writeln; if you'll take a look into druntime sources, you'll find that string is just an alias to `immutable(char)[]`. so you actually

Re: Issue with template function

2015-02-07 Thread Charles via Digitalmars-d-learn
On Saturday, 7 February 2015 at 12:04:12 UTC, Nicholas Wilson wrote: Are you wanting to to convert each element in arr to a byte thus truncating and losing data (when T.sizeof != 1)? as in toBytes([1,2,3, 42, 500 /*this will be truncated to 244 */]);// T == int here or are you wanting to

Issue with template function

2015-02-06 Thread Charles via Digitalmars-d-learn
I'm trying to create a template function that can take in any type of array and convert it to a ubyte array. I'm not concerned with endianness at the moment, but I ran into a roadblock when trying to do this with strings. It already works with ints, chars, etc. Here's the relevant test code:

Re: Issue with template function

2015-02-06 Thread Charles via Digitalmars-d-learn
Can I not do this cast because it's immutable?

Question about Vectors

2014-11-20 Thread Charles via Digitalmars-d-learn
So I was reading the documentation page: http://dlang.org/simd.html and noticed what appears to be a typo: int4 v; (cast(int*)v)[3] = 2; // set 3rd element of the 4 int vector (cast(int[4])v)[3] = 2; // set 3rd element of the 4 int vector v.array[3] = 2; // set 3rd element of the 4

ODBC Library?

2014-11-10 Thread Charles via Digitalmars-d-learn
Hi guys, I've been looking and haven't found any libraries for ODBC or MSSQL. I saw some for D v1, but nothing for v2. Anyone know of any, or anyone know of a tutorial that I could use to create this myself? Thanks, Charles

Re: ODBC Library?

2014-11-10 Thread Charles via Digitalmars-d-learn
I kinda slapped one together but idk if it actually works. https://github.com/adamdruppe/arsd database.d and mssql.d from that repo. I haven't even tried to compile it for a while though, so it might not work at all. The way I made it was to write the extern(C) function declarations and

Re: ODBC Library?

2014-11-10 Thread Charles via Digitalmars-d-learn
On Monday, 10 November 2014 at 18:13:58 UTC, Adam D. Ruppe wrote: On Monday, 10 November 2014 at 17:57:21 UTC, Charles wrote: It didn't compile, says, mssql.d(12): Error: module sql is in file 'win32\sql.d' which cannot be read Oh, I forgot I used those. You can download the win32 folder

Possible difference in compilers?

2014-08-31 Thread Charles via Digitalmars-d-learn
Hi everyone So I've been working on the problems over at HackerRank.com trying to gain some familiarity with D. I use a Windows computer with VisualD, but the server used to test the program uses Ubuntu (I can't tell which compiler they're actually using). The problem I'm stuck on now is the

Re: Possible difference in compilers?

2014-08-31 Thread Charles via Digitalmars-d-learn
For the test cases this only produces the first output (correctly), but then hits a compiler error with format.d before the next one. Any ideas what might be going on? Figured it out. The issue was the \n character at the end of the readf statements.