Re: Help with Ranges
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 with map's source, I think I know how to proceed from here. I really appreciate your patience, and next time I'll clearly explain my constraints. Thank you, gentlemen.
Re: Help with Ranges
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 come after the mapping, and there are more operations done to the range after sort: arr.map!doSomething.sort. ...; [...] As Steven said, you cannot sort a range that doesn't support swapping elements, and most ranges cannot unless they're backed by actual storage, like an array. (*Something* has got to keep track of where the elements are, after all.) But in my example, isn't the output of map backed by actual storage? After all, it's taking in an array. In this particular case, though, if the contents of your original doesn't need to be preserved, perhaps .schwartzSort might be what you're looking for? If you cannot modify the original array for whatever reason, then an allocation is probably unavoidable -- either you'll have to create an array of your mapped elements, or you could create an index and sort that instead (see .makeIndex or std.range.zip for different approaches). T I'll take a look at both of these, since I need to be aware of both cases. I'm trying to find the most efficient way of building a pipeline for my own betterment. Thank you.
Re: Help with Ranges
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 before the transformations. I have found this handy tool quite useful in my code where I need a temporary array: // creates a concrete range (std.container.array.Array range) out of the // original range that is eagerly fetched, and then can be processed, without // allocating extra garbage on the heap. auto concreteRange(Range)(Range r) { import std.range : ElementType; import std.container.array : Array; return Array!(ElementType!Range)(r)[]; } Slicing an Array will keep the reference count correctly, and destroy the memory automatically after you're done using it. So it's perfect for temporary arrays in pipelining. -Steve This works well, and it's rather nifty. Still, I'm confused since, as far as I know, map wraps its source, i.e. the array in this case, which is sortable. It seems to me the only reason I can't sort MapResult is because it doesn't have the proper interface. I'm obviously missing something.
Help with Ranges
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 because the range it's receiving doesn't support element swapping. This may and might be resolved by calling array: arr.map!doSomething.array.sort. ...; However, this might trigger an allocation, and there's still more to do! Is there something I'm missing with regards to ranges that could help me make the first line work without using array, or is it more of an issue with my code's design?
Re: Setup help?
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 is possible that it will require Visual Studio Build Tools installation) Of course this will not work for default DMD builds because it is using ancient object files format that is not compatible with VS debugger engine, so using DMD you need to build with -m32mscoff (dub --arch=x86_mscoff) or -m64 (dub --arch=x86_64) flags. Thanks, I'll give it a shot.
Setup help?
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 normal/exepcted configuration. My most recent attempt I tried to get Native Debug to make VS Code debugging stop on the first line. Instead, it just runs the program, and exits. Debug console output: No symbol table is loaded. Use the "file" command. Running executable [New Thread 10256.0x23d8] [New Thread 10256.0x2d30] [New Thread 10256.0xebc] [New Thread 10256.0x19f4] Edit source/app.d to start your project. [Thread 10256.0xebc exited with code 0] [Thread 10256.0x2d30 exited with code 0] [Thread 10256.0x19f4 exited with code 0] Thanks
Re: We gunna be rich
On Saturday, 2 April 2016 at 19:12:19 UTC, Suliman wrote: Do you have any plans to public 2 edition of The D Programming Language book? I'd buy it.
Re: Great new website
On Friday, 4 March 2016 at 10:43:27 UTC, Joakim wrote: I wonder what percentage of traffic is now mobile? I know I only use mobile these days, ie I haven't used a "desktop" browser since late last year (though my 8.4" tablet that I use most of the time has 4 million pixels, more than most desktop/laptop monitors). I'm sure the recent redesign made the site a lot more convenient for a lot of users if mobile use is becoming widespread. In general, its around a third in worldwide figures I've seen (not dlang specific though). http://gs.statcounter.com/#all-browser_version-ww-monthly-201601-201603-bar 16% Chrome (Android) 10% Safari (iOS) 5% Android Browser 4% UC Browser
Re: In language tooling
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
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 CTFE? I think he makes a decent case for whether or not it'd be useful.
Re: dlang.io subdomains
On Monday, 29 February 2016 at 15:25:01 UTC, Seb wrote: Hey all, I was quite astonished that the dlang.io domain was still available. I imagine it could be used to host non-official user projects and give them a fancy name. FYI the main website dlang.io currently redirects to dlang.org, but if anyone has a better use case for it - let me know! So if anyone is interested in this offer for a subdomain (e.g. your-awesome-project.dlang.io), just ping me (seb [at] wilzba [dot] ch) - I am more then happy to help you ;-) A few off that make sense to be reserved: * code.dlang.io: code.dlang.org * forum.dlang.io: forum.dlang.org * (etc) * science.dlang.io: dlangscience.github.io/ * derelict.dlang.io: github.com/DerelictOrg * vibe.dlang.io: vibed.org (maybe web.dlang.io, but perhaps that's overstepping some bounds?)
Re: Syntax highlighting of backticks now supported in Notepad++
On Tuesday, 23 February 2016 at 17:01:47 UTC, Andre wrote: Hi, with the newest version of Notepad++ (6.9) strings enclosed with backticks `Hello World!` are now correctly highlighted. Kind regards André And here I've been escaping double quotes for years. Didn't know this was a thing. Thanks!
Re: Unum II announcement
On Tuesday, 23 February 2016 at 15:12:38 UTC, John Colvin wrote: On Tuesday, 23 February 2016 at 13:46:33 UTC, Charles wrote: On Tuesday, 23 February 2016 at 08:49:50 UTC, John Colvin wrote: If you don't find people with D, this might be an opportunity. There is https://bitbucket.org/bachmeil/dmdinline2 This seems to be the opposite of what I'd need unfortunately. Why not? You can easily wrap that inside some R and no-one would know it was D. Because I looked at the wrong example, sorry. Now that I know it fits the bill it just needs Windows support (beyond docker) to be really practical.
Re: Unum II announcement
On Tuesday, 23 February 2016 at 08:49:50 UTC, John Colvin wrote: I saw you looking for heavy math users. I work with quite a few actuaries, but I probably wouldn't be able to convince them to use anything if there wasn't a way to use it with either SAS or R. SAS can import C functions, but that's about it in terms of interop. If you don't find people with D, this might be an opportunity. There is https://bitbucket.org/bachmeil/dmdinline2 This seems to be the opposite of what I'd need unfortunately. The likelihood of convincing them to use D is probably zero. In general, they're closer to mathematicians then programmers.
Re: Unum II announcement
On Monday, 22 February 2016 at 21:27:31 UTC, Nick B wrote: On Monday, 22 February 2016 at 17:15:54 UTC, Charles wrote: On Monday, 22 February 2016 at 13:11:47 UTC, Guillaume Piolat wrote: Slide 12, 0101 is repeated. The top one should actually be 0111 I believe (this error also repeats). I will check with John re this error. Aside from that, the notes were super useful, not sure if you could add them in there. Its likely that we can not add the Notes to the PDF, which is why I recommended to everyone, to download the presentation, and read it via Powerpoint, then you can see all the Notes. Nick I saw you looking for heavy math users. I work with quite a few actuaries, but I probably wouldn't be able to convince them to use anything if there wasn't a way to use it with either SAS or R. SAS can import C functions, but that's about it in terms of interop. If you don't find people with D, this might be an opportunity.
Re: Unum II announcement
On Monday, 22 February 2016 at 13:11:47 UTC, Guillaume Piolat wrote: On Monday, 22 February 2016 at 11:34:25 UTC, Guillaume Piolat wrote: PDF link: http://www.pdf-archive.com/2016/02/22/multicore2016-jlg/multicore2016-jlg.pdf Just a heads up: Unfortunately there's an issue with the fonts as well as some typos in this. Ex: Slide 3 the infinity and minus signs don't show up in symbol font on my PC (Win7 w/ Office 2013). This reoccurs for every copy of the diagram. Slide 12, 0101 is repeated. The top one should actually be 0111 I believe (this error also repeats). Aside from that, the notes were super useful, not sure if you could add them in there.
Re: Is this a good singleton?
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 every come of the std.patterns idea?
Re: Questions about vibe.d
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: https://github.com/rejectedsoftware/vibe.d/tree/master/examples/https_server 2. I'd do this with nginx. Example: http://serverfault.com/a/337893 3. Yes. 4. Yes. Example: https://github.com/rejectedsoftware/vibe.d/tree/master/examples/sendmail Sorry if these questions are a bit basic, the implied subtext is "and does it work well?". Yes, also Sönke actively works one Vibe almost (if not) every single day, so it's also exceptionally well maintained.
Re: Questions about vibe.d
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 (and SPDY)... https://en.wikipedia.org/wiki/HTTP/2 Vibe.d doesn't though. There's a branch for it here: https://github.com/rejectedsoftware/vibe.d/tree/http2-botan-cleanup, but it still has a good bit of work.
algorithm's .filter!() by range key
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
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 % 2 == 1 ).sum(); // sum odd elements in array x.filter!(x_key => x_key % 2 == 1).sum(); Oh man, I really messed up my example, and did a poor one at that. Better example: auto x = [2,4,6,8,10]; x.filter( x_key => x_key % 2 == 1 ).sum(); // sums 2 + 6 + 10 == 18
Re: algorithm's .filter!() by range key
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 ).sum(); // sum odd elements in array An array is not an indexed range. It only works with foreach by key because of special foreach behavior. What you want is std.range.enumerate Exactly! Thanks! Interestingly, hackerrank doesn't seem to have it. They're using 2.067.0-b1 on Ubuntu 14.04.
Re: Proposal: Database Engine for D
On Saturday, 6 February 2016 at 13:41:03 UTC, Piotrek wrote: For the rest there is my proposal ;) : a language embedded DB. As far as I can tell none of the known PLes has this "killer" feature. Piotrek SAS does, and has for quite a few decades now. Its a pretty big corporate language used for statistics and analysis. It does work exceptionally well, easily handling well over 100M records within a single table. They implement a table per file (sas7bdat). That said, the binary table format is proprietary, and while there have been attempts to reverse engineer it none have been completely successful.
Re: Dwarf Exception Handling now on FreeBSD!
On Monday, 1 February 2016 at 03:23:18 UTC, Walter Bright wrote: They have bits and pieces of the info, but nothing about what is actually generated to, say, catch an exception. Gotcha, is this something you'd expect to be easily obtainable (e.g. ask Microsoft Rep saying we want to make it easier for people to use their product?), or is this something that would probably require some sort of reverse engineering effort?
Re: Dwarf Exception Handling now on FreeBSD!
On Sunday, 31 January 2016 at 06:34:26 UTC, Walter Bright wrote: Well, here's a ripe plum for anyone wanting valuable compiler street cred! Make the Dwarf EH support work on OSX 32 and 64. Are there any future plans for Win64 since it won't ever support dwarf exceptions from how I understand it? Or does it, and I'm strongly mistaken?
Re: Do D need a popular framework? like ruby's rails? or java 's ssh?
On Tuesday, 19 January 2016 at 14:02:52 UTC, wobbles wrote: On Tuesday, 19 January 2016 at 13:22:48 UTC, beck wrote: Do D need a popular framework? in china ,a little peopel use dlang. i just use it do some simple work for myself. yet,i have learn d for a week .. i ask so many friends ,they don't use D at all.we use golang more than dlang. There is vibe-d, which I guess can be used like rails (I dont use rails myself, so could be mistaken). http://vibed.org/ It's actually pretty far off from Rails. Rails is an MVC framework that has its own ORM using the ActiveRecord pattern. Vibe does provide a very good base for such a framework to be written though.
Re: Tutorials section on vibed.org
On Monday, 4 January 2016 at 18:42:32 UTC, Sönke Ludwig wrote: Am 04.01.2016 um 19:04 schrieb Pradeep Gowda: On Monday, 4 January 2016 at 14:31:21 UTC, Sönke Ludwig wrote: Added! The footer of the website still says 2012-2014. Please fix that! Fixed, thanks! Looks like this on my phone (ignore the volume overlay, screenshot key is dumb): http://imgur.com/ynuZUpq
Re: Writing a scalable chat room service in D
On Monday, 4 January 2016 at 10:19:52 UTC, Sönke Ludwig wrote: Finally published the article that I had prepared in autumn last year. It gives an overview of the basic functionality needed to implement a typical web application using vibe.d. The example uses Redis as a data store - using other storage solutions may be a good topic for a follow-up article. https://vibed.org/blog/posts/a-scalable-chat-room-service-in-d Reddit: https://www.reddit.com/r/programming/comments/3ze948/writing_a_scalable_chat_room_service_in_d/ Wish I knew this was being worked on. I had something similar over at: http://wiki.dlang.org/User:Csmith1991/Vibe.d_Documentation/websocket
Re: vibe.d benchmarks
On Tuesday, 29 December 2015 at 22:49:36 UTC, Nick B wrote: On Monday, 28 December 2015 at 13:10:59 UTC, Charles wrote: On Monday, 28 December 2015 at 12:24:17 UTC, Ola Fosheim Grøstad wrote: https://www.techempower.com/benchmarks/ The entries for vibe.d are either doing very poorly or fail to complete. Maybe someone should look into this? Sönke is already on it. http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/post/29110 Correct me if I am wrong here, but as far I can tell there is no independent benchmarks showing performance (superior or good enough) of D verses Go, or against just about any other language, as well ? https://www.techempower.com/benchmarks/#section=data-r11=peak=json=cnc=zik0vz-zik0zj-zik0zj-zik0zj-hra0hr The last time the official benchmark was run was over a month before Sönke's PR.
Re: vibe.d benchmarks
On Monday, 28 December 2015 at 12:24:17 UTC, Ola Fosheim Grøstad wrote: https://www.techempower.com/benchmarks/ The entries for vibe.d are either doing very poorly or fail to complete. Maybe someone should look into this? Sönke is already on it. http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/post/29110
Re: What is happening here?
On Sunday, 27 December 2015 at 15:10:07 UTC, TheDGuy wrote: I don't understand this: https://www.youtube.com/watch?v=j_VCa-5VeP8=youtu.be The variable "discriminant" is below zero but it jumps right into the if statement? The video is private, so we can't see it. I think you wanted unlisted. Also you might've wanted the learn forum.
Re: Redesign of dlang.org
On Friday, 25 December 2015 at 14:04:36 UTC, anonymous wrote: On 25.12.2015 12:51, Jacob Carlborg wrote: Most of the pages do not seem to be updated. I don't know what you mean. Could this be a cache thing? Can you give a specific example, maybe with a screenshot? The drop down in the search fields looks very bad in Safari on OS X. I think this is a general problem with bootstrap. This version doesn't use Bootstrap anymore. I just changed some details from the current dlang.org, the core mechanism should work the same. If the current dlang.org looks ok, but mine doesn't, then I must have messed up something. It looks fine for me, though, and I have no OS X around to check. Further assistance would be appreciated. I'm away from my computer atm, so I'll just point you to www.browserstack.com. It's also free for open source projects. Test to your heart's content.
Re: Redesign of dlang.org
On Tuesday, 22 December 2015 at 15:01:52 UTC, Dmitry wrote: On Tuesday, 22 December 2015 at 13:38:48 UTC, Charles wrote: That's silliness, and not how percentages work at all. To suggest that 95% of people that go to dlang.org have widescreens because 95% of some other user base is nonsense. 1) Do you have statistics of dlang.org? This is entirely my point. I don't, and I can't tell from your response that you do either. 2) Do you think that dlang.org statisitcs will be very different with world statistics? I don't think so. Yes. I'd suspect the number of people using phones to visit a programming language website would be smaller than, say, Facebook. I have no way of telling though. Do you? It's better to not assume. 3) Do you think that % of 4:3 displays will not drop? In all world it decrease each month. Websites need to be maintained just like anything else. That's the entire point of this thread. I used statistics from my professional sphere, but ok, lets try google any other. For example, http://www.w3schools.com/browsers/browsers_display.asp 1024x768 Jan 2015: 4% 1280x1024 Jan 2015: 7% 1366x768 33% 1920x1080 16% They state right on the page that its only visitors of w3schools.com, so... people interested in learning web development. Other way. Check any shop. How many new monitors 4:3 (or 5:4) it have, and how many widescreen? Check, how many new 4:3 models have, for example, LG? One. Asus? No one. Any other company? Only a few, right? Trend is that % of 4:3 displays goes to be 0 soon. Completely correct. Now, how many monitors support a vertical orientation? Just because its uncommon doesn't mean its not done. Opinion. I agree with you, but why alienate anyone? It's not like narrow websites are unusable. They're just not your preference. For people like Ola, wide websites are legitimately unusable. I did not say that site must be only for widescreen. Keywords: Responsive Web Design. Go ahead and Google that. I can almost guarantee you one of the first things you'll find is "Mobile First". Yeah, its still a big deal. To be fair, D's documentation uses a left-side menu, but it removes the top level navigation (you have to press the logo). Yep, new design has _same_ solution. The new design was a rough draft. It also didn't even implement documentation navigation, it merely served as a proof-of-concept. I'd call that more of a design flaw than a feature. Do you have more good ideas? I'd suggest using left navigation for documentation navigation, and a top bar for main site navigation. On small screen width, instead of a left navigation, it'd just be a list for each module page, and a back button on the module pages. I'd have to play with it a bit to figure out how I'd want it for sure though.
Re: Redesign of dlang.org
On Tuesday, 22 December 2015 at 08:52:28 UTC, Dmitry wrote: On Tuesday, 22 December 2015 at 08:04:29 UTC, Ola Fosheim Grøstad wrote: I use exclusively 4:3 and 3:4, 1600*1280, 1280*1024, 1024*1280, 1024*768 and 768*1024. Yep, you are one of that 5%. That's silliness, and not how percentages work at all. To suggest that 95% of people that go to dlang.org have widescreens because 95% of some other user base is nonsense. The reason web designers have a strong preference towards tall sites vs wide sites is twofold. Firstly, its hard to collect meaningful statistics on their own users, because browser dimensions might be set based on the existing site design. Secondly they need to design for mobile screens anyways, because request headers suggest they account for over 50% of internet users. That said, that's something that should also be specifically checked per website. Widescreen is for movies... No. Opinion. I agree with you, but why alienate anyone? It's not like narrow websites are unusable. They're just not your preference. For people like Ola, wide websites are legitimately unusable. Besides, many programmers with wide screen does not have multiple monitors, Many programmers do not have. But other many programmers have. I use multiple monitors, 16:9 and 4:3. All studios, where I worked, uses multiple monitors. Most part of professional developers, who I personally know, uses multiple monitors. So, this is not an argument. Again, I agree with the sentiment, but anecdotal evidence isn't a legitimate argument to block design changes. Example anecdotal counter-argument: Even though I have 3 x widescreen monitors, I generally only have any one web page on a sixth of my total screen space, which favors a narrow format. so they need space both for website and editor on same screen. Firstly, in most cases it will be D documentation. And it anyway will use left-side menu. And second - current design already support small width. To be fair, D's documentation uses a left-side menu, but it removes the top level navigation (you have to press the logo). I'd call that more of a design flaw than a feature.
Re: Redesign of dlang.org
On Monday, 21 December 2015 at 19:54:45 UTC, Andrei Alexandrescu wrote: On 12/21/2015 02:43 PM, Jack Stouffer wrote: IMO we should stay away from trans-plied languages like SCSS, Less, and CoffeeScript, for several reasons [snip] That sounds reasonable. -- Andrei Meanwhile, we could also consider the [U.S. Government's standards] (https://playbook.cio.gov/designstandards/), which do explicitly suggest using SCSS. On the other hand, also explicitly state not to use Bootstrap. It also recommends a few different m**w js frameworks (like angular), but don't think it mentions coffeescript one way or another iirc. From what I've seen, these standards are actually exceptionally well written.
Re: Redesign of dlang.org
On Saturday, 19 December 2015 at 14:33:35 UTC, Jacob Carlborg wrote: [...] kind of a neat project here... mind if I help out?
Re: What complexity have a log(sum) shape?
On Tuesday, 8 December 2015 at 20:56:28 UTC, cym13 wrote: On Tuesday, 8 December 2015 at 17:33:49 UTC, Andrei Alexandrescu wrote: On 12/08/2015 12:12 PM, Timon Gehr wrote: O(log(n+m)) = O(log(n)+log(m)). Noice. Yes I did miss it. Thx!! -- Andrei Surely I'm missing something obvious but why is it true exactly? Im confident it isn't. I think the rule he was thinking of was O(log(ab)) = O(log(a)+log(b)), which is just a basic property of logarithms. It's pretty easy to get to a contradiction between those two rules.
Re: What complexity have a log(sum) shape?
On Tuesday, 8 December 2015 at 21:18:01 UTC, Timon Gehr wrote: On 12/08/2015 09:56 PM, cym13 wrote: On Tuesday, 8 December 2015 at 17:33:49 UTC, Andrei Alexandrescu wrote: On 12/08/2015 12:12 PM, Timon Gehr wrote: O(log(n+m)) = O(log(n)+log(m)). Noice. Yes I did miss it. Thx!! -- Andrei Surely I'm missing something obvious but why is it true exactly? n+m ≤ 2·max(n,m). (1) max(n,m) ≤ n+m. (2) Hence, log(n+m) ≤ log(max(n,m)) + log(2) by (1) = max(log(n),log(m)) + log(2) by monotonicity ≤ log(n) + log(m) + log(2) by (2), log(n)+log(m) ≤ 2·max(log(n),log(m))by (1) = 2·log(max(n,m)) by monotonicity ≤ 2·log(n+m) by " and (2). Similar arguments work for any monotone increasing function that does not grow too fast. This seems reasonable, but you have undefined behavior of logarithms if n or m is zero.
Re: Advent of Code
On Tuesday, 1 December 2015 at 22:57:38 UTC, Ali Çehreli wrote: My visit was short due to this: To play, please identify yourself via one of these services: [github] [google] [twitter] [reddit] Ali I was the same way earlier, but reddit doesn't need personal information, so you can just make a throwaway account. Did the first question and it was painfully simple. SPOILERS (stop reading here if you want to do it) !!! auto input = "arbitrarily long string of '(' and ')'"; int floor; foreach(movement; input) floor += (movement == '(' ? 1 : -1); writeln(floor);
Re: Build utf.d with MS-COFF failed
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: DLL Subsystem : Not set Compilation: Combined compile and link Thank you for your help. What string is throwing the error? I've had that error when I was trying to decode windows1252 strings.
Thought on the 2015H2 Vision Participation Goal
Hi everyone, Just looked at the vision for this half, and I had an idea pop in my head. Before I get to that idea, let me explain what I think might be an issue with it as-is. I've consistently seen D's participation metrics marked by the number of pull requests created and closed, which is great. This gives us input as to how active people are on actually developing the core part of D. Unfortunately it doesn't give us an indication as to what caused this number to increase. Was it new users? Was it people becoming more familiar being more productive? Etc. While I don't doubt participation is correlated to pull request counts, I don't think its a great indicator of new users. Furthermore, I don't know if this can scale. We get small dedicated group capable of taking out 3-5 issues a month each, and where does that leave us? With a lot of issues open probably. How do we fix that? Ask the small dedicated group to take more time out of their, presumably busy, life and fix our problems for us. # So what should we do instead? Why not try and target people who haven't worked on a language previously that are interested in doing so, but don't know where to get started. I definitely fall into this group. I know there's something I could do that would be useful, but I don't know how to find it to get it done. I just wish there was something out there that literally baby stepped me through the entire process. Yeah, I might not be tackling extremely difficult problems right out of the gate, but if there was even 20% of our issues that the only thing holding them up is a lack of someone assigned to them, this could be a huge win for everyone. # What could we do to accomplish this? Here's where I think that reorienting the goal actually makes the goal a lot more manageable. At the cost of efficiency now, what I (and presumably people like me) need are those baby steps. Ideas could include: * A video about setting up their environment from scratch. This is presumably 1 time thing for most users, but honestly one of the easiest ways to get discouraged. If you're on your own for this it instantly feels like you're going to be on your own for all of it. It really shreds any notion of a community working together. Because of the experience this can cause, and the minimal amount of time that's required to do this, it should be a no-brainer. * Flags for issues that are based on expected completion time for someone reasonably competent with D. As a newcomer, I might not know how involved an issue is. E.g. I don't mind spending 1-3 hours this week, but *every* issue looks like it might unravel on me and take a really long time. * Live code reviews where there can be feedback from experts on how to approach things in a D oriented way. The forums work great for getting a quick answer on something, but a lot of times newcomers don't know the correct question to ask. This kind of interaction is also extremely marketable... look at Jonathan Blow with Jai, and he isn't even letting people use it yet. People interested in helping out with this kind of project need to learn somewhere... why not D? TL;DR: Change our participation goal to be more oriented towards force multiplication. I question whether PR activity is a sustainable metric.
Am I using std.encoding correctly?
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[])[]; const(ubyte)[] buffer = raw[0 .. length]; while (buffer.length > 0) value ~= encodingScheme.decode(buffer); break; ... } I know there's safeDecode, but I'm also fairly confident that all strings can decode safely, already, and if it isn't I'd want an exception thrown from it. Is this correct usage? I guess I was a little surprised there was no decodeString that basically did this.
Re: question about using std.bitmanip.read
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
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 use std.bitmanip.read; however, am having some issues using it. For basic testing I'm just trying to use: read!double(endianess, ubyteArr).writeln; endianess is an Endian from std.system, and ubyteArr is an 8 byte ubyte[]. When I run this I get: Error: template std.bitmanip.read cannot deduce function from argument types !(double)(Endian, ubyte[]), candidates are: std.bitmanip.read(T, Endian endianness = Endian.bigEndian, R)(ref R range) if (canSwapEndianness!T && isInputRange!R && is(ElementType!R : const(ubyte))) dmd failed with exit code 1. Clearly that didn't work, so I tried excluding the endianess: read!double(ubyteArr).writeln; and that does work! But its the wrong byte order, so its incorrect anyways. I went to std.bitmanip to look for unittests using the Endian, and the only one that does uses read!(T, endianness), which needs endianness to be known at compile time, which I don't have. Any suggestions? Cheat! T read(T,R)(Endian endianness , R r) { if(endianness == Endian.bigEndian) return std.bitmanip.read!(T,Endian.bigEndian,R)(r); else if (endianness == Endian.littleEndian) return std.bitmanip.read!(T,Endian.littleEndian,R)(r); } Thanks! but... you are on a little endian system (bigEndian gave wrong byte order ) The actual use case is reading a binary file of unknown endianness. I don't think I'm that fortunate sadly.
question about using std.bitmanip.read
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: read!double(endianess, ubyteArr).writeln; endianess is an Endian from std.system, and ubyteArr is an 8 byte ubyte[]. When I run this I get: Error: template std.bitmanip.read cannot deduce function from argument types !(double)(Endian, ubyte[]), candidates are: std.bitmanip.read(T, Endian endianness = Endian.bigEndian, R)(ref R range) if (canSwapEndianness!T && isInputRange!R && is(ElementType!R : const(ubyte))) dmd failed with exit code 1. Clearly that didn't work, so I tried excluding the endianess: read!double(ubyteArr).writeln; and that does work! But its the wrong byte order, so its incorrect anyways. I went to std.bitmanip to look for unittests using the Endian, and the only one that does uses read!(T, endianness), which needs endianness to be known at compile time, which I don't have. Any suggestions?
Re: Unittest in a library
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"); } } and then build it with `dmd test.d -lib -unittest` and it doesn't fail the unittest. You can test the unittests by using the -main switch. http://dlang.org/dmd-linux.html#switch-main That's exactly what I was missing. Thanks!
Unittest in a library
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?
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 way to just fix this issue altogether?
Re: OneDrive Client written in D
On Wednesday, 23 September 2015 at 13:01:54 UTC, Rory McGuire wrote: I think this should be on reddit either way. Perhaps someone will suggest a way around the oauth2 limitation. Having to generate new client secrets just to use an app that already exists seems like a mission, so providing a default set that work and the user can just make sure they get the original app seems more practical. i.e. download binary from a reputable place i.e. your distributions repos. Also you are doing the same way everyone else does it; by prompting at the command line sooo I don't know to much about oauth2, but could we in theory add a layer of security by only allowing some client id that has a sort of checksum based on the source code of the application? I don't know how client ids are generated, but its just a thought.
What's the "right" way to do openmp-style parallelism?
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 8 GB of floats for(j = 0; j < jmax; j++){ //create some local variables. for(i = 0; i < imax; i++){ x[j][i] = complicatedFunction(i, x[j-1], other, local, variables); } } In C, I'd just stick a #pragma omp parallel for around the inner loop (since the outer loop obviously can't be parallelized). How should I go about this in D? I want to avoid copying data around if it's possible since these arrays are huge. Cheers, Charles.
Re: forum.dlang.org, version 2 (BETA)
Any change of making the D Logo redirect to dlang.org rather than the forum itself?
Re: [OT] Regarding most used operating system among devs
On Wednesday, 8 April 2015 at 16:13:22 UTC, Adam D. Ruppe wrote: On Wednesday, 8 April 2015 at 16:08:44 UTC, Dicebot wrote: So who is going to do the pull request? One of those Linux developers I presume? :) I actually came close to it, but it ended up being a bit of a pain. The easiest thing would be to just shove the win32.* packages in the zip, but then you ahve the hassle of HANDLE being different in core.sys.windows.windows and win32... and I wanted to merge them but it wasn't as easy as it should be, then other stuff came up. But maybe the path of least resistance is worth doing. Or perhaps the core.sys.windows could simply import win32 instead of adapting them hmmm. That's tempting. tho then I hit the problem of me having three jobs already and don't have a lot of time I'm of the opposite end, where I have the time; however, I don't understand exactly what needs done. I've been meaning to get more familiar with the Win32 API anyhow. Perhaps we could tag team this? Feel free to get a hold of me if you're interested.
Re: [OT] Regarding most used operating system among devs
On Wednesday, 8 April 2015 at 15:41:42 UTC, bachmeier wrote: On Wednesday, 8 April 2015 at 08:59:04 UTC, Szymon Gatner wrote: To sum up: Please give more attention to Windows developers like myself ;) We could turn that around: Windows developers, please step up to contribute to the development of D. I don't know if that's necessarily fair. I asked last week about finding the Win32 API for D. It exists, but it hasn't been touched in awhile, and still exists on dsource (not code.dlang.org). We have core.sys.windows.windows, but it's pretty terrible atm in this front.
Re: Win32 bindings
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, create your own from .def files, or use implib/coffimplib. Are the default libraries in dmd2\windows\lib not current or something?
Win32 bindings
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 aware that there's core.sys.windows.windows, but the documentation for this page is less than helpful: http://dlang.org/library/core/sys/windows/windows.html. It also seems to be missing portions of it that'd be useful (see github here: https://github.com/D-Programming-Language/druntime/tree/master/src/core/sys/windows). So, perhaps, a better question is what do you use for win32 bindings? Are there any additional dependencies when building apps with either of these (beyond something like user32.dll for example)? Thanks, Charles
Re: Enhancement: issue error on all public functions that are missing ddoc sections
On Thursday, 19 March 2015 at 11:27:20 UTC, Gary Willoughby wrote: I would like this but issue warnings not errors. I like every function to be documented. Also don't make the Example mandatory because people tend to use unittest blocks as the examples. Why not just make unittests mandatory, and completely forego the examples?
Let's Play Code Golf
For the uninitiated, Code Golf is producing the correct answer to a question with minimal syntax (whitespace included). I found a couple questions on HackerRank, which allows D compilation. So far there's only two entries for D (mine and another) for the first problem. Here's the problem: In Calculus, the Leibniz formula for π is given by: 1 - 1/3 + 1/5 - 1/7 + 1/9 - ... = pi/4 You will be given an integer n. Your task is to print the summation of the Leibniz formula up to the nth term of the series correct to 15 decimal places. Input Format The first line contains the number of test cases (T) which is less than 100. Each additional line is a test case for a positive integer value (p) less than 10^7. Sample Input 2 10 20 Output Format Output T lines, with each line containing the summation up to nth term. Sample Output 0.760459904732351 0.772905951666960 Scoring This is a code golf question. The goal is to write a solution with as little code as possible. A correct submission with a source code of X characters will receive the following score: maxScore * (300 - X)/300 Any correct code longer than 300 characters will receive a score of maxScore * 0.001. MaxScore is the maximum score attainable for the problem. Note that whitespace is also treated as a character. My solution (150 characters, 15 points): void main(){import std.stdio;int t,n;readf( %d,t);while(t--){readf( %d,n);real a=0,i=0;for(;in;i++)a+=(i%2?-1:1)/(i+i+1);writefln(%.15f,a);}} Link to problem site: https://www.hackerrank.com/challenges/leibniz Anyone care to do better? :)
Re: Let's Play Code Golf
I didn't beat your score, but I did it with ranges (full character count was 174): stdin.readln(); foreach(x; stdin.byLine) writefln(%0.15f, map!(a = (a1?-1:1)/(2.0*a+1))(iota(x.to!int)).sum); I think if I didn't have to import so many things, I would have done much better :) -Steve Yeah, imports were my issue too. Especially with readln, because using that meant I needed std.conv. Why don't reals initialize to zero? That'd save me 4 characters! :P
Re: curl password issue
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 adds anything. You're sure it isn't an issue with your program or how you pass the password? This might be the case here. I was recently dealing with this and I had to percent encode the hash key (%23 for reference). Also, I ran into issues regarding the http_proxy and https_proxy environment variables, but again those are unrelated to curl.d.
Re: Let's Play Code Golf
On Monday, 23 February 2015 at 23:10:32 UTC, anonymous wrote: On Monday, 23 February 2015 at 20:21:20 UTC, Charles wrote: My solution (150 characters, 15 points): void main(){import std.stdio;int t,n;readf( %d,t);while(t--){readf( %d,n);real a=0,i=0;for(;in;i++)a+=(i%2?-1:1)/(i+i+1);writefln(%.15f,a);}} Link to problem site: https://www.hackerrank.com/challenges/leibniz Anyone care to do better? :) 126: void main(){import std.stdio;real n,a;for(readln;a=0,readf( %f,n);writefln(%.15f,a))while(--n=0)a+=(n%2?-1:1)/(n+n+1);} Nice going. I didn't realize that the exponent operator was outside of std.math with ^^ which is why I used the ternary operator to achieve the same results, importing the standard library is probably the most expensive thing for this challenge. Yay learning things. With that in mind, and switching around --n to n--, we can get the code down to 120 characters: void main(){import std.stdio;real n,a=0;for(readln;readf( %f,n);writefln(%.15f,a))while(n--)a+=(-1)^^n/(n+n+1);} On Tuesday, 24 February 2015 at 00:03:55 UTC, bearophile wrote: Steve Sobel: It can get down to 155 using ranges, but those imports really are killer. You usually don't want to design a language for code golfing (but several exist, like http://esolangs.org/wiki/GolfScript ). Yeah I know that they're languages designed for this, but they feel like cheating for sure. Plus, GolfScript would be kinda odd on DLang's forums ;)
Re: vibe-d basic build errors
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 run only the link command with a -v to get verbose dmd output? dmd -c -of.dub\build\application-debug-windows-x86-dmd_2066-7FF336D92D4F5796EA8623FC9A6A9B90\web.obj -debug -g -w -version=VibeDefaultMain -version=VibeWin32Driver -version=Have_web -version=Have_vibe_d -version=Have_openssl -Isource -IC:\Users\Charles\AppData\Roaming\dub\packages\vibe-d-0.7.22\source -IC:\Users\Charles\AppData\Roaming\dub\packages\openssl-1.1.3_1.0.1g -Jviews source\app.d C:\Users\Charles\AppData\Roaming\dub\packages\vibe-d-0.7.22\source\vibe\appmain.d Thanks for the help with this. The link command ran without error, and it's output is here: http://pastebin.com/eqT4vst6 To be exact, the command I ran was this: dmd -v -c -of.dub\build\application-debug-windows-x86-dmd_2066-7FF336D92D4F5796EA8623FC9A6A9B90\web.obj -debuenssl -Isource -IC:\Users\Charles\AppData\Roaming\dub\packages\vibe-d-0.7.22\source -IC:\Users\Charles\AppData\-d-0.7.22\source\vibe\appmain.d %userprofile%\Desktop\output.txt It didn't produce any errors as far as I can tell, but I'm not sure how to tell what the mangled function names are. Sorry about the delay in getting back to you on this. Charles
Re: vibe-d basic build errors
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 vibe.d? Looks like the existing vibe.d lib was build against a different build of druntime. Yes, I have. Here's a pastebin with --force --vverbose: http://pastebin.com/qZEKUN46
Re: vibe-d basic build errors
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 interesting questions. - What version of dub and dmd are you using? - Are those installer versions or did you build anything yourself? They're installer versions, dub is 0.9.22 Nov 22 I want to say, and DMD is 2.066.1
vibe-d basic build errors
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: http://pastebin.com/4BcHJM74 Thanks, Charles
Re: Issue with template function
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 doing thing: readString(toBytes!(immutable(char)[])(test),0,4).writeln; i bet that this is not what you meant. ;-) Thanks!
Re: Issue with template function
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 convert each element to a ubyte array and then concatenate it to the result. as is ubyte[] toBytes(T)(T[] arr) { ubyte[T.sizeof] buf; if (arr is null) { return null; } ubyte[] result = new ubyte[arr.length * T.sizeof]; foreach (i, val; arr) { buf[] = cast(ubyte[T.sizeof])(arr[i])[0 .. T.sizeof] result ~= buf; } return result; } ? The original code I was using was written in Java, and only had a method for strings. This is closer to what I wanted. My unit tests were just going back and forth with readString function, so I was completely missing this for other types. Nice catch! There were a couple issues with your code so I've included the corrected version: ubyte[] toUbytes(T)(T[] arr) { if (arr is null) { return null; } ubyte[T.sizeof] buffer; ubyte[] result = new ubyte[arr.length * T.sizeof]; foreach (i, val; arr) { buffer[] = cast(ubyte[T.sizeof])((arr[i]))[0 .. T.sizeof]; // Parenthesis and missing semicolon result[i * T.sizeof .. (i * T.sizeof) + T.sizeof] = buffer; // Specify appropriate slice for buffer to be inserted into } return result; }
Issue with template function
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: module byteReader; public import std.system : Endian; ubyte[] toBytes(T)(T[] arr) { if (arr == null) { return null; } ubyte[] result = new ubyte[arr.length]; foreach (key, val; arr) { result[key] = cast(ubyte) val;// This is line 16 } return result; } string readString(ubyte[] buffer, uint offset, uint length) { assert( buffer.length = offset + length ); char[] chars = new char[length]; foreach(key, val; buffer[offset .. offset + length]) { chars[key] = cast(char) val; } return cast(string)chars; } void main() { import std.stdio; readString(toBytes!char(['t','e','s','t']),0,4).writeln; readString(toBytes!string(test),0,4).writeln;// This is line 39 } Here's the output: byteReader.d(16): Error: cannot cast val of type string to type ubyte byteReader.d(39): Error: template instance byteReader.toBytes!string error instantiating
Re: Issue with template function
Can I not do this cast because it's immutable?
Question about Vectors
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 int vector v.ptr[3] = 2;// set 3rd element of the 4 int vector v.array[3] = 2; and v.ptr[3] = 2; set the fourth element, and not the third. As I was verifying this, I realized I had to compile it in 64 bit code. The 32 bit code produced the error SIMD vector types not supported on this platform. My test code is: void main() { import std.stdio; import core.simd; int4 v = 7; v.ptr[3] = 2; writeln(v.array[]); } Is that related to me compiling while using a 64 bit OS, or is that true of any 32 bit OS, and thus, vectors can't be used in programs intended to be run on 32 bit OSs? Thanks, Charles
ODBC Library?
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?
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 then call it like in C. It didn't compile, says, mssql.d(12): Error: module sql is in file 'win32\sql.d' which cannot be read and then lists the import paths, of which none of them have the win32 directory. Database.d was able to compile though. Assuming you're using ODBC on Windows, here's an old port of an even older C++ wrapper I used to use for ODBC work. It includes an ODBC header and library, so should serve as a good basis for whatever you're trying to do. If you're on Unix, you may have to update the ODBC header a bit. I got partway through that project back in the day but never finished: http://invisibleduck.org/sean/tmp/sql.zip I'll look into this, thanks for the example.
Re: ODBC Library?
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 from here https://github.com/AndrejMitrovic/DWinProgramming/tree/master/WindowsAPI The Windows bindings that come with phobos are pathetically incomplete so a separate download or a bunch of copy/pasted declarations is needed for any serious windows api work. Thanks for that. For anyone in the future: I needed odbc32.lib, so I created the following odbc32.def and used implib. LIBRARY odbc32 EXETYPE NT SUBSYSTEM WINDOWS EXPORTS _SQLAllocEnv@4 = SQLAllocEnv _SQLAllocConnect@8 = SQLAllocConnect _SQLAllocHandle@12 = SQLAllocHandle _SQLColAttribute@28 = SQLColAttribute _SQLConnect@28 = SQLConnect _SQLDisconnect@4 = SQLDisconnect _SQLDescribeCol@36 = SQLDescribeCol _SQLDriverConnect@32 = SQLDriverConnect _SQLDrivers@32 = SQLDrivers _SQLDataSources@32 = SQLDataSources _SQLExecDirect@12 = SQLExecDirect _SQLFetch@4 = SQLFetch _SQLFreeConnect@4 = SQLFreeConnect _SQLFreeHandle@8 = SQLFreeHandle _SQLFreeEnv@4 = SQLFreeEnv _SQLEndTran@12 = SQLEndTran _SQLFreeStmt@8 = SQLFreeStmt _SQLGetData@24 = SQLGetData _SQLGetDiagField@28 = SQLGetDiagField _SQLGetDiagRec@32 = SQLGetDiagRec _SQLGetInfo@20 = SQLGetInfo _SQLNumResultCols@8 = SQLNumResultCols _SQLSetConnectOption@12 = SQLSetConnectOption _SQLSetEnvAttr@16 = SQLSetEnvAttr _SQLSetStmtOption@12 = SQLSetStmtOption I've only tested it on a couple select statements and the fieldNames, but so far its working.
Possible difference in compilers?
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 Utopian Tree (https://www.hackerrank.com/challenges/utopian-tree). My solution I came up with (and works locally) is: import std.stdio; void main() { int height=1,t=1,oldN=0,n; readf( %d\n, t); foreach (i;0 .. t) { readf( %d\n, n); foreach (j; oldN .. n) height = (j % 2) ? height + 1 : height * 2; writeln(height); oldN = n; } } 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? Thanks, Charles
Re: Possible difference in compilers?
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.
Cryptography and D
Is there a native D crypto library like Crypto++?