Re: mod of negative number

2024-09-23 Thread Craig Dillabaugh via Digitalmars-d-learn
On Monday, 23 September 2024 at 20:02:25 UTC, Craig Dillabaugh wrote: On Monday, 23 September 2024 at 19:52:02 UTC, Craig Dillabaugh wrote: Why does the following program: snip Opps, sorry. I was expecting 7680 (not -1 or 5568). After a bit of research I see this is the same behavior as C

Re: mod of negative number

2024-09-23 Thread Craig Dillabaugh via Digitalmars-d-learn
On Monday, 23 September 2024 at 19:52:02 UTC, Craig Dillabaugh wrote: Why does the following program: \ import std.stdio; int main(string[] args) { uint Q = 7681; writeln("Val = ", -1 % Q); return 0; } \ Print

Re: UI Library

2022-05-19 Thread Craig Dillabaugh via Digitalmars-d-learn
On Friday, 20 May 2022 at 02:37:48 UTC, harakim wrote: I need to write a piece of software to track and categorize some purchases. It's the kind of thing I could probably write in a couple of hours in C#/Java + html/css/javascript. However, something keeps drawing me to D and as this is a simpl

Re: Bug in std.json or my problem

2020-04-22 Thread Craig Dillabaugh via Digitalmars-d-learn
On Wednesday, 22 April 2020 at 18:35:49 UTC, CraigDillabaugh wrote: On Wednesday, 22 April 2020 at 18:23:48 UTC, Anonymouse wrote: On Wednesday, 22 April 2020 at 17:48:18 UTC, Craig Dillabaugh wrote: clip File an issue if you have the time, maybe it will get attention. Unreported bugs can

Bug in std.json or my problem

2020-04-22 Thread Craig Dillabaugh via Digitalmars-d-learn
So perhaps I am the only person in the world using std.json, but I was wondering if the following code should work. = import std.json; import std.conv; import std.stdio; struct Person { string name; float income; t

Re: How the hell to split multiple delims?

2020-02-15 Thread Craig Dillabaugh via Digitalmars-d-learn
On Saturday, 15 February 2020 at 11:32:42 UTC, AlphaPurned wrote: I've tried 10 different ways with split and splitter, I've used all the stuff that people have said online but nothing works. I always get a template mismatch error. Why is something so easy to do so hard in D? auto toks = std.

Re: To learn D

2019-07-05 Thread Craig Dillabaugh via Digitalmars-d-learn
On Friday, 5 July 2019 at 12:00:15 UTC, Binarydepth wrote: I've considering learning full D. I remembered that D is not recommended as a first language, So I read time ago. So my question, is learning C and Python a good intro before learning D? TY Ali's book is targeted at beginners (see

Re: more OO way to do hex string to bytes conversion

2018-02-06 Thread Craig Dillabaugh via Digitalmars-d-learn
On Wednesday, 7 February 2018 at 03:25:05 UTC, rikki cattermole wrote: On 06/02/2018 8:46 PM, Craig Dillabaugh wrote: On Tuesday, 6 February 2018 at 18:46:54 UTC, H. S. Teoh wrote: [...] clip [...] clip [...] Wouldn't it be more accurate to say OO is not the correct tool for ever

Re: more OO way to do hex string to bytes conversion

2018-02-06 Thread Craig Dillabaugh via Digitalmars-d-learn
On Tuesday, 6 February 2018 at 18:46:54 UTC, H. S. Teoh wrote: On Tue, Feb 06, 2018 at 06:33:02PM +, Ralph Doncaster via Digitalmars-d-learn wrote: clip OO is outdated. D uses the range-based idiom with UFCS for chaining operations in a way that doesn't require you to write loops yourse

Re: Object oriented programming and interfaces

2017-12-04 Thread Craig Dillabaugh via Digitalmars-d-learn
On Monday, 4 December 2017 at 20:43:27 UTC, Dirk wrote: Hi! I defined an interface: interface Medoid { float distance( Medoid other ); uint id() const @property; } and a class implementing that interface: class Item : Medoid { float distance( Item i ) {...} uint id() const @pr

Re: Help with an algorithm!

2017-06-15 Thread CRAIG DILLABAUGH via Digitalmars-d-learn
On Thursday, 15 June 2017 at 13:41:07 UTC, MGW wrote: On Thursday, 15 June 2017 at 13:16:24 UTC, CRAIG DILLABAUGH wrote: The purpose - search of changes in file system. Sorting is a slow operation as well as hashing. Creation of a tree, is equally in sorting. So far the best result: string

Re: Help with an algorithm!

2017-06-15 Thread CRAIG DILLABAUGH via Digitalmars-d-learn
On Thursday, 15 June 2017 at 11:48:54 UTC, Ivan Kazmenko wrote: On Thursday, 15 June 2017 at 06:06:01 UTC, MGW wrote: There are two arrays of string [] mas1, mas2; Size of each about 5M lines. By the size they different, but lines in both match for 95%. It is necessary to find all lines in an a

Re: Check of point inside/outside polygon

2016-07-27 Thread CRAIG DILLABAUGH via Digitalmars-d-learn
On Wednesday, 27 July 2016 at 14:56:13 UTC, Suliman wrote: On Wednesday, 27 July 2016 at 12:47:14 UTC, chmike wrote: On Wednesday, 27 July 2016 at 09:39:18 UTC, Suliman wrote: clip Sorry, its my issue I am thinging about polygons, but for me would be enought points. The problem is next. I am

Re: Check of point inside/outside polygon

2016-07-27 Thread Craig Dillabaugh via Digitalmars-d-learn
On Wednesday, 27 July 2016 at 09:39:18 UTC, Suliman wrote: On Wednesday, 27 July 2016 at 08:40:15 UTC, chmike wrote: The algorithm is to draw a horizontal (or vertical) half line starting at your point and count the number of polygon edges crossed by the line. If that number is even, the point

Re: AA with dynamic array value

2016-07-05 Thread Craig Dillabaugh via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 02:33:02 UTC, ketmar wrote: On Wednesday, 6 July 2016 at 02:19:47 UTC, Craig Dillabaugh wrote: [...] this is true for any dynamic array, including AAs. until something is added to array, it actually a `null` pointer. i.e. arrays (and AAs) generally consisting of

Re: AA with dynamic array value

2016-07-05 Thread Craig Dillabaugh via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 02:03:54 UTC, Adam D. Ruppe wrote: On Wednesday, 6 July 2016 at 01:58:31 UTC, Craig Dillabaugh wrote: *(keyvalue) ~ value; // This line fails. That should prolly be ~= instead of ~. Ahh, I was so close. Thank you that seems to do the trick. However

AA with dynamic array value

2016-07-05 Thread Craig Dillabaugh via Digitalmars-d-learn
How can I create (and update) and associative array where the key is a string, and the value is a dynamic array of integers? For example: void insertValue( int[][string]aa, string key, int value ) { int[]* keyvalue; keyvalue = ( key in aa ); if ( keyvalue !is null ) { *

Re: Issue with 2.071: Regression or valid error?

2016-04-06 Thread Craig Dillabaugh via Digitalmars-d-learn
On Wednesday, 6 April 2016 at 19:01:58 UTC, Craig Dillabaugh wrote: On Wednesday, 6 April 2016 at 15:10:45 UTC, Andre wrote: clip Not so up to date on D's OOP stuff, but don't you want create() to be protected, not private. You can typically access a private method through a

Re: Issue with 2.071: Regression or valid error?

2016-04-06 Thread Craig Dillabaugh via Digitalmars-d-learn
On Wednesday, 6 April 2016 at 15:10:45 UTC, Andre wrote: Hi, With 2.071 following coding does not compile anymore and somehow I feel it should compile. The issue is with line "cat.create();". Cat is a sub type of Animal. Animal "owns" method create and I want to call the method create within

Re: How is D doing?

2015-12-23 Thread Craig Dillabaugh via Digitalmars-d-learn
On Thursday, 24 December 2015 at 00:16:16 UTC, rsw0x wrote: On Tuesday, 22 December 2015 at 21:38:22 UTC, ZombineDev wrote: On Tuesday, 22 December 2015 at 17:49:34 UTC, Jakob Jenkov wrote: clip removed C++ because it just dwarfs the others. D, as I expected, has a massive following in Japan

Re: DUB linking to local library

2015-08-04 Thread Craig Dillabaugh via Digitalmars-d-learn
On Tuesday, 4 August 2015 at 08:18:58 UTC, John Colvin wrote: On Tuesday, 4 August 2015 at 03:20:38 UTC, Craig Dillabaugh wrote: I can now run it with: LD_LIBRARY_PATH=/home/craig2/code/gdal-2.0.0/lib64 ./gdaltest But it appears the LD_LIBRARY_PATH hack is causing havoc with other libraries

Re: DUB linking to local library

2015-08-04 Thread Craig Dillabaugh via Digitalmars-d-learn
On Tuesday, 4 August 2015 at 04:21:27 UTC, Joakim Brännström wrote: On Tuesday, 4 August 2015 at 03:20:38 UTC, Craig Dillabaugh wrote: clip Linkers, so fun they are... https://wiki.debian.org/RpathIssue As you can see in the search order RPATH takes precedence over LD_LIBRARY_PATH. If we

Re: DUB linking to local library

2015-08-03 Thread Craig Dillabaugh via Digitalmars-d-learn
On Tuesday, 4 August 2015 at 02:45:21 UTC, Joakim Brännström wrote: On Tuesday, 4 August 2015 at 02:26:17 UTC, Craig Dillabaugh wrote: So how can I force my application to link to my local copy of GDAL2 at /home/craig2/code/gdal-2.0.0/lib64. Any help is appreciated. Hi, I recently ran into

DUB linking to local library

2015-08-03 Thread Craig Dillabaugh via Digitalmars-d-learn
er, I also have the older GDAL libraries (1.11) installed system wide on my machine. My GDAL bindings have the following dub.json file: { "name": "gdald", "description": "D bindings for the Geospatial Data Abstraction Library (GDAL).", &qu

Re: Binding Nested C Structs

2015-07-09 Thread Craig Dillabaugh via Digitalmars-d-learn
On Friday, 10 July 2015 at 03:38:49 UTC, Craig Dillabaugh wrote: I am trying to bind to a C union with a number of nested structs declared as follows: typedef union { int Integer; struct { int nCount; int *paList; } IntegerList; struct

Binding Nested C Structs

2015-07-09 Thread Craig Dillabaugh via Digitalmars-d-learn
I am trying to bind to a C union with a number of nested structs declared as follows: typedef union { int Integer; struct { int nCount; int *paList; } IntegerList; struct { int nCount; GIntBig *paList; } Integer64List; }

Re: Converting void* to D array

2015-04-14 Thread Craig Dillabaugh via Digitalmars-d-learn
On Wednesday, 15 April 2015 at 04:43:39 UTC, Daniel Kozák wrote: On Wed, 15 Apr 2015 04:24:20 + Craig Dillabaugh via Digitalmars-d-learn wrote: Hi. I want to call a C library function that returns a data buffer as a void*. How do I convert the resulting void* into something I can

Converting void* to D array

2015-04-14 Thread Craig Dillabaugh via Digitalmars-d-learn
Hi. I want to call a C library function that returns a data buffer as a void*. How do I convert the resulting void* into something I can process in D? //I have the following function from the GDAL C library. extern(C) CPLErr GDALReadBlock( GDALRasterBandH, int, int, void* ); So I have (GB

Re: Contributing to Phobos Documentation

2015-03-21 Thread Craig Dillabaugh via Digitalmars-d-learn
On Saturday, 21 March 2015 at 21:53:00 UTC, H. S. Teoh wrote: On Sat, Mar 21, 2015 at 05:48:40PM +, Craig Dillabaugh via Digitalmars-d-learn wrote: Motivated by this thread: http://forum.dlang.org/thread/measc3$qic$1...@digitalmars.com I was hoping to see if I could do some work on the

Contributing to Phobos Documentation

2015-03-21 Thread Craig Dillabaugh via Digitalmars-d-learn
Motivated by this thread: http://forum.dlang.org/thread/measc3$qic$1...@digitalmars.com I was hoping to see if I could do some work on the Phobos documentation, but I am curious to know what the easiest way for someone with limited/no ddoc experience to get involved in this would be. I check

Re: Dlang seems like java now,but why not let d more like C# Style?

2015-03-14 Thread Craig Dillabaugh via Digitalmars-d-learn
On Saturday, 14 March 2015 at 09:59:05 UTC, dnewer wrote: yes,java is good lang,but i dont think it's better than c#,if no oracle or google support java will less and less. C# is a good and easy lang. i like C# . but,C# cant compiled to native code. So far, I have been searching for a language,

Re: Getting started with vibe.d

2014-06-03 Thread Craig Dillabaugh via Digitalmars-d-learn
On Tuesday, 3 June 2014 at 17:41:27 UTC, Chris Saunders wrote: Thanks, I somehow missed the vibe.d forums... I'd need an ldc solution in the end, but trying dmd is a good idea. The result is some kind of link error to libevent?: """ dub build vibe-d: ["vibe-d", "libevent", "openssl"] test: [

Re: Getting started with vibe.d

2014-06-03 Thread Craig Dillabaugh via Digitalmars-d-learn
On Tuesday, 3 June 2014 at 16:16:10 UTC, Chris Saunders wrote: I've made my first attempt to use dub/vibe.d and I'm running into some issues I can't find on the list. I'm on Ubuntu 14.04/x86_64, using the latest stable dub (0.9.21). I can create a new dub project: “”” $ dub init test vibe.d

Re: D Newbie Trying to Use D with Major C Libraries

2014-05-15 Thread Craig Dillabaugh via Digitalmars-d-learn
On Friday, 16 May 2014 at 01:16:46 UTC, Craig Dillabaugh wrote: On Thursday, 15 May 2014 at 22:25:47 UTC, Tom Browder via Digitalmars-d-learn wrote: I am a volunteer developer with the well-known 3D CAD FOSS project BRL-CAD: http://brlcad.org I have wanted to use D for a long time but I

Re: D Newbie Trying to Use D with Major C Libraries

2014-05-15 Thread Craig Dillabaugh via Digitalmars-d-learn
using DUB. For example here is the DUB config file for one of my library bindings (in my case I used a static library though): { "name": "shplib", "description": "D bindings for Shapelib. Shapefile reader.", "ho

Re: Writing to stdin of a process

2014-04-26 Thread Craig Dillabaugh via Digitalmars-d-learn
On Saturday, 26 April 2014 at 13:30:41 UTC, Adam D. Ruppe wrote: On Saturday, 26 April 2014 at 08:45:59 UTC, Craig Dillabaugh wrote: Can anyone tell me what I am dong wrong. In this case, I'd close the pipe when you're done. pipes.stdin().writeln("Hello world");

Writing to stdin of a process

2014-04-26 Thread Craig Dillabaugh via Digitalmars-d-learn
I want to be able to write to the stdin stream of an external process using std.process. I have the following small test app. myecho.d -- import std.stdio; void main(string[] args) { foreach (line; stdin.byLine()) { std

Re: Example of parse whole json answer.

2014-04-24 Thread Craig Dillabaugh via Digitalmars-d-learn
On Thursday, 24 April 2014 at 12:17:42 UTC, Nicolas wrote: I have a json string saved in a file ( example of json tweeter answer: https://dev.twitter.com/docs/api/1.1/get/statuses/user_timeline ). I am trying to read the whole json answer and print specific data ("created_at", "retweet_count",

Re: Improving IO Speed

2014-03-14 Thread Craig Dillabaugh
On Friday, 14 March 2014 at 18:00:58 UTC, TJB wrote: I have a program in C++ that I am translating to D as a way to investigate and learn D. The program is used to process potentially hundreds of TB's of financial transactions data so it is crucial that it be performant. Right now the C++ versi

Re: [video tutorial] Defensive programming with Design By Contract basics

2014-02-20 Thread Craig Dillabaugh
On Thursday, 20 February 2014 at 10:28:45 UTC, simendsjo wrote: http://youtu.be/wFqHTCBt72M Thanks for posting these. They are well done. What text editor are you using, emacs?

Re: DMD exit code -9

2014-02-20 Thread Craig Dillabaugh
On Wednesday, 19 February 2014 at 23:45:12 UTC, Etienne Cimon wrote: On 2014-02-19 17:15, Craig Dillabaugh wrote: However, I would still be interested in finding out where I could get a listing of what the various exit codes mean ... or do I need to delve into the DMD source code? That

Re: DMD exit code -9

2014-02-20 Thread Craig Dillabaugh
On Thursday, 20 February 2014 at 08:10:06 UTC, simendsjo wrote: On Wednesday, 19 February 2014 at 22:15:47 UTC, Craig Dillabaugh wrote: (...) I just realized that I tried to build this on my Linode, where DMD tends to choke and die with anything Vibe-d related (basic Linodes have very little

Re: DMD exit code -9

2014-02-19 Thread Craig Dillabaugh
On Wednesday, 19 February 2014 at 22:07:55 UTC, Craig Dillabaugh wrote: I am trying to build a small application (I am using DUB) and when I try to build, I get the following output: dub build dub: /usr/lib64/libcurl.so.4: no version information available (required by dub) vibe-d: ["v

DMD exit code -9

2014-02-19 Thread Craig Dillabaugh
I am trying to build a small application (I am using DUB) and when I try to build, I get the following output: dub build dub: /usr/lib64/libcurl.so.4: no version information available (required by dub) vibe-d: ["vibe-d", "libevent", "openssl"] vibe-d: ["vibe-d", "libevent", "openssl"] libd: [

Re: Optimize my code =)

2014-02-14 Thread Craig Dillabaugh
On Friday, 14 February 2014 at 16:47:32 UTC, John Colvin wrote: On Friday, 14 February 2014 at 16:40:31 UTC, Craig Dillabaugh wrote: On Friday, 14 February 2014 at 16:00:09 UTC, Robin wrote: this(size_t rows, size_t cols) { this.dim = Dimension(rows, cols); this.data = new T

Re: Optimize my code =)

2014-02-14 Thread Craig Dillabaugh
On Friday, 14 February 2014 at 16:00:09 UTC, Robin wrote: this(size_t rows, size_t cols) { this.dim = Dimension(rows, cols); this.data = new T[this.dim.size]; enum nil = to!T(0); foreach(ref T element; this.data) element = nil; } I am no expert at optimizing D co

Re: How can i find my LAN IP Address using std.socket?

2014-02-04 Thread Craig Dillabaugh
On Tuesday, 4 February 2014 at 16:13:33 UTC, Dicebot wrote: On Tuesday, 4 February 2014 at 16:02:33 UTC, Craig Dillabaugh wrote: However if I run /sbin/ifconfig I get: enp7s0Link encap:Ethernet HWaddr 50:E5:49:9B:29:49 inet addr:10.1.101.52 Bcast:10.1.101.255 Mask

Re: How can i find my LAN IP Address using std.socket?

2014-02-04 Thread Craig Dillabaugh
On Tuesday, 4 February 2014 at 15:48:50 UTC, Vladimir Panteleev wrote: On Tuesday, 4 February 2014 at 13:02:26 UTC, TheFlyingFiddle wrote: I'm trying to find my own ip address using std.socket with little success. How would i go about doing this? (It should be a AddressFamily.INET socket) Thi

Re: 3d vector struct

2014-02-03 Thread Craig Dillabaugh
type to support only floating-point values, so you can see here how types can be restricted to FP (see line 50). https://github.com/craig-dillabaugh/phobos/blob/master/std/complex.d Thats my fork of the Phobos libraries, likely a bit out of date, but I was too lazy to look up the prope URL.

Re: core.stdc.config

2014-01-30 Thread Craig Dillabaugh
On Thursday, 30 January 2014 at 09:03:47 UTC, Gary Willoughby wrote: On Thursday, 30 January 2014 at 03:28:57 UTC, Craig Dillabaugh wrote: So, there is a module core.stdc.config (referenced here): http://dlang.org/interfaceToC.html That is presumably part of the D Standard library. I am

Re: core.stdc.config

2014-01-30 Thread Craig Dillabaugh
On Thursday, 30 January 2014 at 07:26:51 UTC, Jacob Carlborg wrote: On 2014-01-30 05:42, Mike Parker wrote: All of the core.* modules are part of DRuntime, not Phobos. Unfortunately none of the core.stdc.* modules are documented. It's understandable that duplicating the documentation of the

core.stdc.config

2014-01-29 Thread Craig Dillabaugh
So, there is a module core.stdc.config (referenced here): http://dlang.org/interfaceToC.html That is presumably part of the D Standard library. I am curious to know why no mention of this library is included at: http://dlang.org/phobos/index.html Is it not part of Phobos? Are there standard

Re: Simplest way to create an array from an associative array which its contains keys and values?

2014-01-07 Thread Craig Dillabaugh
On Tuesday, 7 January 2014 at 20:52:40 UTC, H. S. Teoh wrote: On Tue, Jan 07, 2014 at 08:38:10PM +, Craig Dillabaugh wrote: [...] As someone with little experience with functional programming, I am just curious - having browsed through the thread - if the various solutions proposed here

Re: Simplest way to create an array from an associative array which its contains keys and values?

2014-01-07 Thread Craig Dillabaugh
On Friday, 3 January 2014 at 17:38:16 UTC, Gary Willoughby wrote: Simplest way to create an array from an associative array which its contains keys and values? For example if i have an associative array like this: ["one":"1", "two":"2"] What's the easiest way to create a dynamic array that lo

Re: A good advertisement for 'static if'

2013-12-12 Thread Craig Dillabaugh
On Thursday, 12 December 2013 at 17:34:13 UTC, FreeSlave wrote: On Thursday, 12 December 2013 at 14:55:28 UTC, Craig Dillabaugh wrote: I am not sure if this belongs in D.learn, but it might be of interest. I was writing some C++ code for a project at work and have a class that stores image

A good advertisement for 'static if'

2013-12-12 Thread Craig Dillabaugh
I am not sure if this belongs in D.learn, but it might be of interest. I was writing some C++ code for a project at work and have a class that stores image data from a file. The image data can be in just about any numeric (int/float/complex) type, so I wanted a 'wrapper' class/struct that cou

Re: Help Finding Strange Memory Bug (Code linked to C library)

2013-12-08 Thread Craig Dillabaugh
On Saturday, 7 December 2013 at 23:35:49 UTC, Ali Çehreli wrote: On 12/07/2013 03:11 PM, Rémy Mouëza wrote: > the last pointer, `double * padfMaxBound` is actually a pointer to an array > of 4 elements: Great sleuthing! :) This thread is a good example of "C's Biggest Mistake": http://www.dr

Re: Help Finding Strange Memory Bug (Code linked to C library)

2013-12-08 Thread Craig Dillabaugh
hough one might reasonably assume that the bounds on a multidimensional dataset would have more than one dimension. Thank you. On 12/07/2013 04:29 PM, Craig Dillabaugh wrote: Hello, I recently wrote bindings to the C-library Shapelib (it reads/writes a common file format used in Geograp

Help Finding Strange Memory Bug (Code linked to C library)

2013-12-07 Thread Craig Dillabaugh
Hello, I recently wrote bindings to the C-library Shapelib (it reads/writes a common file format used in Geographic Information Systems). I've been trying to write a small test program to make sure my bindings 'work' and I've come across a bizarre memory bug. I THINK I've identified the co

Re: How to convert these constructs to D?

2013-12-01 Thread Craig Dillabaugh
On Sunday, 1 December 2013 at 18:51:51 UTC, Gary Willoughby wrote: On Sunday, 1 December 2013 at 03:20:49 UTC, Craig Dillabaugh wrote: On Saturday, 30 November 2013 at 14:53:35 UTC, Gary Willoughby wrote: I'm porting some C headers and wondered how would i convert the following to D: #d

Re: How to pass a null pointer to a C function

2013-11-30 Thread Craig Dillabaugh
On Sunday, 1 December 2013 at 04:11:57 UTC, Simen Kjærås wrote: On 2013-12-01 04:46, Craig Dillabaugh wrote: Since questions about calling C from D seem to be popular today, I thought I would throw this one out there. I am trying to call a C function which takes as parameters several arrays

How to pass a null pointer to a C function

2013-11-30 Thread Craig Dillabaugh
Since questions about calling C from D seem to be popular today, I thought I would throw this one out there. I am trying to call a C function which takes as parameters several arrays of doubles. It is valid to have some arrays passed a NULL pointers in the C code. To call this from D I've com

Re: How to convert these constructs to D?

2013-11-30 Thread Craig Dillabaugh
On Saturday, 30 November 2013 at 14:53:35 UTC, Gary Willoughby wrote: I'm porting some C headers and wondered how would i convert the following to D: #define pthread_self() GetCurrentThreadId() #define pthread_handler_t void * __cdecl typedef void * (__cdecl *pthread_handler)(void *); #defin

Re: Two Questions about Linking to C libraries

2013-11-27 Thread Craig Dillabaugh
On Wednesday, 27 November 2013 at 07:30:58 UTC, Jacob Carlborg wrote: On 2013-11-27 02:26, Craig Dillabaugh wrote: 2. Once I think my bindings are stable I would like to add them to Deimos or DUB registries. Are there any recommendations for testing bindings? I checked through some other

Re: Two Questions about Linking to C libraries

2013-11-26 Thread Craig Dillabaugh
On Wednesday, 27 November 2013 at 02:36:01 UTC, Jesse Phillips wrote: Don't have answers. Do you still get segfault removing SHPClose( hShp ); Yep. Other comment: writeln("Bounds = [" ~to!string(pad_min_bound) ~ "," ~ to!string(pad_max_bound) ~ "]"); writeln("B

Two Questions about Linking to C libraries

2013-11-26 Thread Craig Dillabaugh
I recently created bindings to the C libary shapelib. http://shapelib.maptools.org/ I generated my own bindings by hand, and another set of bindings with DStep. I created a small test program to test my bindings. My current test program in its entirety is: import std.stdio; import std.str

Re: Immutable Red-Black trees

2013-11-25 Thread Craig Dillabaugh
On Tuesday, 26 November 2013 at 01:31:11 UTC, bearophile wrote: Craig Dillabaugh: What do you mean by an 'immutable' data structure. The linked article talks about Persistent data structures. Are these the same thing? When I saw "Immutable" I figured it didn't su

Re: Immutable Red-Black trees

2013-11-25 Thread Craig Dillabaugh
On Tuesday, 26 November 2013 at 01:21:49 UTC, Craig Dillabaugh wrote: On Tuesday, 26 November 2013 at 00:28:34 UTC, bearophile wrote: clip Bye, bearophile What do you mean by an 'immutable' data structure. The linked article talks about Persistent data structures. Are these

Re: Immutable Red-Black trees

2013-11-25 Thread Craig Dillabaugh
On Tuesday, 26 November 2013 at 00:28:34 UTC, bearophile wrote: Bartosz Milewski has written the second article about immutable data structures in C++11, this time about Red-Black trees: http://bartoszmilewski.com/2013/11/25/functional-data-structures-in-c-trees/ The C++11 code with few small c

Re: DStep

2013-11-24 Thread Craig Dillabaugh
On Sunday, 24 November 2013 at 14:04:32 UTC, Jacob Carlborg wrote: On 2013-11-24 14:58, Craig Dillabaugh wrote: I have clang installed on my machine. Is there anyway to point dstep to the right headers when I invoke it? Yes, use the -I flag. In addition to the listed flags, DStep accept

Re: DStep

2013-11-24 Thread Craig Dillabaugh
On Sunday, 24 November 2013 at 13:01:15 UTC, Gary Willoughby wrote: On Friday, 22 November 2013 at 14:35:45 UTC, Craig Dillabaugh wrote: I am trying to use DStep on OpenSuse 12.3. I downloaded one of the binaries (it was for Debian, so I guess that is my problem), and when I run DStep I get

Re: DStep

2013-11-24 Thread Craig Dillabaugh
On Sunday, 24 November 2013 at 13:05:04 UTC, Jacob Carlborg wrote: On 2013-11-24 06:37, Craig Dillabaugh wrote: Thanks. That is how I started out trying to fix it (Well, I used symlinks rather than copy the files, but basically the same). I got it to stop complaining about stddef.h and

Re: DStep

2013-11-23 Thread Craig Dillabaugh
On Saturday, 23 November 2013 at 20:16:32 UTC, Jacob Carlborg wrote: On 2013-11-22 15:35, Craig Dillabaugh wrote: I am trying to use DStep on OpenSuse 12.3. I downloaded one of the binaries (it was for Debian, so I guess that is my problem), and when I run DStep I get the following error

DStep

2013-11-22 Thread Craig Dillabaugh
I am trying to use DStep on OpenSuse 12.3. I downloaded one of the binaries (it was for Debian, so I guess that is my problem), and when I run DStep I get the following error: craigkris@linux-s9qf:~/code/DShape/D> dstep shapefil.h File(850DF8, "")/usr/include/stdio.h:33:11: fatal error: 'stddef.

Re: Optimization tips for alpha blending / rasterization loop

2013-11-22 Thread Craig Dillabaugh
On Friday, 22 November 2013 at 10:27:12 UTC, bearophile wrote: Craig Dillabaugh: Do you want to use a ubyte instead of a byte here? See: http://d.puremagic.com/issues/show_bug.cgi?id=3850 Bye, bearophile Yes it is pretty easy to mix that up. A lot of my work is with images with single

Re: std.json

2013-11-20 Thread Craig Dillabaugh
On Wednesday, 20 November 2013 at 13:48:37 UTC, Orvid King wrote: On 11/20/13, Craig Dillabaugh wrote: On Wednesday, 20 November 2013 at 13:29:54 UTC, Dicebot wrote: What I mean is that std.json does not seem to be written with such usage mode in mind, it is more about direct DOM manipulation

Re: std.json

2013-11-20 Thread Craig Dillabaugh
On Wednesday, 20 November 2013 at 13:29:54 UTC, Dicebot wrote: What I mean is that std.json does not seem to be written with such usage mode in mind, it is more about direct DOM manipulation/construction. So probably examples should probably not highlight how bad it is at tasks it is really bad

Re: std.json

2013-11-20 Thread Craig Dillabaugh
On Wednesday, 20 November 2013 at 13:20:48 UTC, Dicebot wrote: For tasks that imply conversion between D types and JSON text (alike to serialization), vibe.d module is really much superior because it provides functions like http://vibed.org/api/vibe.data.json/serializeToJson which "just work"

Re: std.json

2013-11-20 Thread Craig Dillabaugh
On Monday, 26 March 2012 at 07:14:50 UTC, Ali Çehreli wrote: On 03/25/2012 08:26 AM, AaronP wrote: Could I get a "hello, world" example of parsing json? The docs look simple enough, but I could still use an example. For what it's worth, I've just sent the following program to a friend before

Re: Instantiating templates where type is known only at run time

2013-11-19 Thread Craig Dillabaugh
On Tuesday, 19 November 2013 at 12:53:50 UTC, bearophile wrote: Craig Dillabaugh: // Assume images are of the same dimensions. Result is // saved in Out. void add(T,U,V)(Image!T A, Image!U B, Image!V Out) { ... } Take a look at the "out" annotation in D. Anyway, thanks

Instantiating templates where type is known only at run time

2013-11-19 Thread Craig Dillabaugh
this question came up in some C++ work I am doing, but since the solutions are likely nicer in D, I wanted to ask how it could be solved in D. First for some motivation. I am doing image processing work where the images are simply an array of data, where the data type can be any numeric type. Th

Re: T[] (array of generic type)

2013-11-19 Thread Craig Dillabaugh
On Monday, 18 November 2013 at 20:32:25 UTC, Philippe Sigaud wrote: On Mon, Nov 18, 2013 at 9:20 PM, seany wrote: I read that book, but dont find this constructtion, that is why the question. IIRC I talk a bit about function templates in my tutorial. JR gave the link (thanks!), another, mor

Re: Using reduce() with tuples created by zip()

2013-11-02 Thread Craig Dillabaugh
On Friday, 1 November 2013 at 20:08:15 UTC, Philippe Sigaud wrote: What I'm trying to explain is that reduce takes two arguments: the growing value and the current front. In your case, the current front is indeed a 2-tuple, but that's an unrelated issue. You're trying to get: reduce!( (firstE

Re: Using reduce() with tuples created by zip()

2013-11-01 Thread Craig Dillabaugh
On Friday, 1 November 2013 at 18:44:23 UTC, Philippe Sigaud wrote: reduce!( (result, elem) => result + (elem[0]-elem[1])^^2 )(zippedRange, 0) This is really where my problem arose. I understood everything up to here, but I sort of had this idea, "hey zip returns a tuple so that somehow the

Re: Using reduce() with tuples created by zip()

2013-11-01 Thread Craig Dillabaugh
On Friday, 1 November 2013 at 09:31:41 UTC, Philippe Sigaud wrote: On Thu, Oct 31, 2013 at 8:59 PM, Craig Dillabaugh < cdill...@cg.scs.carleton.ca> wrote: Thanks, I will try both your, and Bearophile's ideas and see if I can figure out how they work. reduce takes a range

Re: Using reduce() with tuples created by zip()

2013-10-31 Thread Craig Dillabaugh
(sum,pair) => sum + (pair[0]-pair[1])^^2 )(zip(pt1, pt2))); } void main() { double[] arr1 = [0.0, 1.0, 0.1]; double[] arr2 = [1.0, -1.0, 0.0]; writeln(euclid_dist(arr1,arr2)); } On Thu, Oct 31, 2013 at 8:12 PM, Craig Dillabaugh < cdill...@cg.scs.carleton.ca> wrote: clip

Using reduce() with tuples created by zip()

2013-10-31 Thread Craig Dillabaugh
I am trying to calculate the Euclidean Distance between two points. I currently have the following function (that doesn't compile): double euclid_dist( double[] pt1, double[] pt2 ) { assert( pt1.length == pt2.length ); return sqrt( zip(pt1, pt2).reduce!(function(e) { return (e[1]-e[0]

Re: Set variable at compile time

2013-10-30 Thread Craig Dillabaugh
On Wednesday, 30 October 2013 at 20:23:58 UTC, Ali Çehreli wrote: On 10/30/2013 01:11 PM, Craig Dillabaugh wrote: > I am writing code that uses a structure containing an array of > points where the points may be of arbitrary dimension (though > generally small). I would like to be abl

Re: Set variable at compile time

2013-10-30 Thread Craig Dillabaugh
On Wednesday, 30 October 2013 at 20:19:11 UTC, Adam D. Ruppe wrote: It won't really work on the command line alone, but the way I do it is a two step thing. First, make the thing use a config module: import myproject.config; alias Thing Thing_Impl!dim; then you go ahead and use Thing, which

Set variable at compile time

2013-10-30 Thread Craig Dillabaugh
Hello, I am writing code that uses a structure containing an array of points where the points may be of arbitrary dimension (though generally small). I would like to be able to pass the point dimension to my structure as a template parameter. One solution is to create instances of these structu

Re: Conflict between std.file write() and std.stdio write()

2013-10-05 Thread Craig Dillabaugh
On Saturday, 5 October 2013 at 02:42:54 UTC, Jonathan M Davis wrote: On Friday, October 04, 2013 16:12:14 Craig Dillabaugh wrote: I guess the more fundamental question is, what is the purpose of the documentation? Is it a quick reference for D users, or is it a resource for people trying to

Re: Conflict between std.file write() and std.stdio write()

2013-10-04 Thread Craig Dillabaugh
On Thursday, 3 October 2013 at 21:58:18 UTC, Jonathan M Davis wrote: On Thursday, October 03, 2013 22:57:22 Craig Dillabaugh wrote: On Thursday, 3 October 2013 at 19:49:07 UTC, Jonathan M Davis wrote: > On Thursday, October 03, 2013 20:57:20 Craig Dillabaugh > wrote: >> On Thursda

Re: Conflict between std.file write() and std.stdio write()

2013-10-03 Thread Craig Dillabaugh
On Thursday, 3 October 2013 at 19:49:07 UTC, Jonathan M Davis wrote: On Thursday, October 03, 2013 20:57:20 Craig Dillabaugh wrote: On Thursday, 3 October 2013 at 18:12:01 UTC, Jonathan M Davis clip > > - Jonathan M Davis Fair enough. As you point out the fix is pretty simple. Howe

Re: Conflict between std.file write() and std.stdio write()

2013-10-03 Thread Craig Dillabaugh
On Thursday, 3 October 2013 at 18:12:01 UTC, Jonathan M Davis wrote: On Thursday, October 03, 2013 15:22:28 Craig Dillabaugh wrote: It seems that std.file should include a writeText() function for the sake of consistency that is the above alias. When you come across readText() in the

Re: Conflict between std.file write() and std.stdio write()

2013-10-03 Thread Craig Dillabaugh
On Thursday, 3 October 2013 at 02:57:50 UTC, Andrej Mitrovic wrote: On 10/3/13, Craig Dillabaugh wrote: void main( string[] args ) { string str = "Hello"; write( "file.txt", str ); string hello_file = readText("file.txt"); writeln( hello_file );

Re: Conflict between std.file write() and std.stdio write()

2013-10-02 Thread Craig Dillabaugh
On Thursday, 3 October 2013 at 00:04:31 UTC, Jonathan M Davis wrote: On Thursday, October 03, 2013 01:39:38 Craig Dillabaugh wrote: Hello, I have the following program: import std.file; import std.stdio; void main( string[] args ) { string str = "Hello"; write( "file.txt&q

Re: Conflict between std.file write() and std.stdio write()

2013-10-02 Thread Craig Dillabaugh
On Thursday, 3 October 2013 at 00:04:31 UTC, Jonathan M Davis wrote: On Thursday, October 03, 2013 01:39:38 Craig Dillabaugh wrote: Hello, I have the following program: import std.file; import std.stdio; void main( string[] args ) { string str = "Hello"; write( "file.txt&q

Re: Conflict between std.file write() and std.stdio write()

2013-10-02 Thread Craig Dillabaugh
On Wednesday, 2 October 2013 at 23:39:39 UTC, Craig Dillabaugh wrote: Hello, I have the following program: import std.file; import std.stdio; void main( string[] args ) { string str = "Hello"; write( "file.txt", str ); string hello_file = readText("file.txt&q

Conflict between std.file write() and std.stdio write()

2013-10-02 Thread Craig Dillabaugh
Hello, I have the following program: import std.file; import std.stdio; void main( string[] args ) { string str = "Hello"; write( "file.txt", str ); string hello_file = readText("file.txt"); writeln( hello_file ); } When I try to compile this I get: test.d(6): Error: std.stdio.wr

Re: Linking Trouble (Linux)

2013-09-30 Thread Craig Dillabaugh
On Sunday, 29 September 2013 at 14:16:21 UTC, 1100110 wrote: https://xkcd.com/979/ Please. You are somebodies hero. Did you actually run into the same problem? If so, glad I could help.

  1   2   >