Re: Get indexes of character in array

2012-03-27 Thread James Miller
On 28 March 2012 19:35, Andrej Mitrovic wrote: > I'd like to get a list of indexes into an array that matches a character. > E.g.: > > "a foo a bar a".indexes("a") == [0, 6, 12] > > Anything like that in Phobos? std.regex might be able to produce something like it. -- James Miller

Re: Get indexes of character in array

2012-03-27 Thread Andrej Mitrovic
On 3/28/12, Andrej Mitrovic wrote: > snip Also a better name might be 'indices'.

Re: Get indexes of character in array

2012-03-27 Thread Andrej Mitrovic
> 3/28/12, Andrej Mitrovic wrote: > I'd like to get a list of indexes into an array that matches a character. > E.g.: > > "a foo a bar a".indexes("a") == [0, 6, 12] Hah I even managed to screw up that "bar" has an 'a' there. Anywho this works just fine: size_t[] indexes(string input, dchar targe

Get indexes of character in array

2012-03-27 Thread Andrej Mitrovic
I'd like to get a list of indexes into an array that matches a character. E.g.: "a foo a bar a".indexes("a") == [0, 6, 12] Anything like that in Phobos?

Re: How to remove element from an SList?

2012-03-27 Thread bearophile
Ali Çehreli: The following worked for me. Note treating the SList as a range by []: import std.container; import std.stdio; import std.algorithm; import std.range; void main() { auto l = SList!int(1, 2, 3, 4, 5, 6, 7); auto a = find(l[], 2); // Search for 2 ... l.linearRemov

Re: How to remove element from an SList?

2012-03-27 Thread Ali Çehreli
On 03/27/2012 05:02 PM, Chris Pons wrote: > Right now i'm struggling with trying to understand how to remove an > element from a n SList. I only want to remove one element, not a range > of elements. I don't have experience with std.container but I think you need to call take(a, 1). > The only

Re: How to remove element from an SList?

2012-03-27 Thread James Miller
On 28 March 2012 13:02, Chris Pons wrote: > Right now i'm struggling with trying to understand how to remove an element > from a n SList. I only want to remove one element, not a range of elements. > I also don't want to use an Array because I will have to reshuffle elements > to take care of the

How to remove element from an SList?

2012-03-27 Thread Chris Pons
Right now i'm struggling with trying to understand how to remove an element from a n SList. I only want to remove one element, not a range of elements. I also don't want to use an Array because I will have to reshuffle elements to take care of the empty spot when I remove it. The only thing I

Re: std.stream.File help required (and classes)

2012-03-27 Thread Ali Çehreli
On 03/27/2012 02:57 PM, akaz wrote: > B) In my function: > private int msf_open(MSFilter* f, void* arg){ //a setter > printf("msf_binfile_open-start\n\n"); > MSF_State* s=cast(MSF_State*)f.data; > ms_mutex_lock(&(f.lock)); > s.filedesc = new File(*(cast(string*)arg),"w

Re: std.stream.File help required (and classes)

2012-03-27 Thread akaz
OK, I converted into using the std.stdio.File. Without success, the programs till crashes. However, in the meantime: A) why there is no parameter-less constructor for std.stdio.File? I would like to have into my "init" function: s.filedesc=new File() and, then, in my setter "open" method s.f

Re: std.stream.File help required (and classes)

2012-03-27 Thread Ali Çehreli
On 03/27/2012 02:20 PM, akaz wrote: > what is the equivalent of > std.stream.File.writeBlock(const void* buffer, size_t size)? I see there > is a std.stdio.rawWrite(T)(in T[] buffer); > > But, my data is: a (byte*) pointer and a length. How do I write > something like > std.stream.File.writeblock

Re: D Dll injection problem

2012-03-27 Thread Gyron
On Tuesday, 27 March 2012 at 21:46:23 UTC, Trass3r wrote: I inject it but it returns nothing and the App(where the dll is injected) is hanging( not responding). Could you try it maybe? I would like to know whether it's a Problem with D or with me. Are dlls without injection working? I don't

Re: D Dll injection problem

2012-03-27 Thread Trass3r
I inject it but it returns nothing and the App(where the dll is injected) is hanging( not responding). Could you try it maybe? I would like to know whether it's a Problem with D or with me. Are dlls without injection working?

Re: D Dll injection problem

2012-03-27 Thread Gyron
On Tuesday, 27 March 2012 at 21:12:59 UTC, Trass3r wrote: Maybe it's because I have no def file. Very possible. Just pass it to dmd like the other files. Or try the new -shared flag. I have tried both now (shared and def file linking), but know it's crashing my App, lol. I inject it but it

Re: std.stream.File help required (and classes)

2012-03-27 Thread akaz
std.file is more about files and directories, not file contents. I've abandoned std.stream.File some time ago. I just use std.stdio.File partly because stdio, stdout, and stderr are of that type anyway. It works with ranges as well. should be re-named std.folder, then, or std.filesystem. havin

Re: D Dll injection problem

2012-03-27 Thread Trass3r
Maybe it's because I have no def file. Very possible. Just pass it to dmd like the other files. Or try the new -shared flag.

Re: D Dll injection problem

2012-03-27 Thread Gyron
On Tuesday, 27 March 2012 at 20:45:52 UTC, maarten van damme wrote: when I tried the previous dmd compiler (have yet to try the curent one on this problem) I got the same problems while trying to compile a dll and use it. I have no clue as to why this is happening. worked in 2.54 I thought I

Re: D Dll injection problem

2012-03-27 Thread maarten van damme
when I tried the previous dmd compiler (have yet to try the curent one on this problem) I got the same problems while trying to compile a dll and use it. I have no clue as to why this is happening. worked in 2.54 I thought

Re: std.stream.File help required (and classes)

2012-03-27 Thread Ali Çehreli
On 03/27/2012 04:58 AM, akaz wrote: > 2. is the std.stream.File the correct choice here? Should I use std.file > instead? Then, why so many file classes (count std.stdio.File too). std.file is more about files and directories, not file contents. I've abandoned std.stream.File some time ago. I j

D Dll injection problem

2012-03-27 Thread Gyron
Hey there, I want to inject a dll which was created in D into a c Program. Informations: DMD vs. 2.058 IDE: MonoDevelop with Mono-D System: Windows 7 64bit Program Informations: 32-bit written in c The Injector is working for sure, so thats not the Problem. the Source of the DLL: import std.c

Re: Printing stacktrace on segfault

2012-03-27 Thread Jérôme M. Berger
simendsjo wrote: > Is there a way to print a stacktrace on segfaults on linux? catchsegv (part of glibc, so should be available on just about all Linux distros...) Jerome -- mailto:jeber...@free.fr http://jeberger.free.fr Jabber: jeber...@jabber.fr signature.asc Descri

Re: Problem about lambda expressions

2012-03-27 Thread Ali Çehreli
On 03/27/2012 06:42 AM, Tongzhou Li wrote: > Hello again! I'm learning D, and I encountered a problem. > I tried this code: > http://ideone.com/hkpT6 > It works well. (Have no idea why codepad.org failed to compile it) > I tried to write a lambda instead of function f, but I got nothing printed.

Re: Printing stacktrace on segfault

2012-03-27 Thread Jonathan M Davis
On Tuesday, March 27, 2012 12:04:59 simendsjo wrote: > Is there a way to print a stacktrace on segfaults on linux? You can do it if you install a signal handler for sigsegv and use backtrace_symbols to construct a stacktrace. Or you can just run the program in gdb or turn core dumps on and use g

Re: std.stream.File help required (and classes)

2012-03-27 Thread akaz
Thank you. But why do I lose access to my std.stream.File file? Somehow, the variable gets unallocated, thus the file is closed back? With pointers of C it used to be so simple... variable remained allocated untel the corresponding free(). I do not quite grasp this (a bit) awkward mix betwee

Re: Problem about lambda expressions

2012-03-27 Thread Kenji Hara
On Tuesday, 27 March 2012 at 13:42:30 UTC, Tongzhou Li wrote: Hello again! I'm learning D, and I encountered a problem. I tried this code: http://ideone.com/hkpT6 It works well. (Have no idea why codepad.org failed to compile it) I tried to write a lambda instead of function f, but I got nothin

Re: std.stream.File help required (and classes)

2012-03-27 Thread Steven Schveighoffer
On Tue, 27 Mar 2012 10:46:08 -0400, H. S. Teoh wrote: On Tue, Mar 27, 2012 at 01:58:03PM +0200, akaz wrote: [...] Now, the questions: 1. why there is std.stdio.File, but also std.stream.File? This gives a conflict and explicit names must then be used to avoid conflict. [...] This is a d

Re: Problem about lambda expressions

2012-03-27 Thread Artur Skawina
On 03/27/12 15:52, Tongzhou Li wrote: > Oh, I also tried: > void seq_apply(Params..., Args...)(void delegate(Params) func, Args args) > But I got a error: > variadic template parameter must be last > Does it mean that there can only be one variadic template parameter? How to > fix it? I'm

Re: std.stream.File help required (and classes)

2012-03-27 Thread H. S. Teoh
On Tue, Mar 27, 2012 at 01:58:03PM +0200, akaz wrote: [...] > Now, the questions: > > 1. why there is std.stdio.File, but also std.stream.File? This > gives a conflict and explicit names must then be used to avoid > conflict. [...] This is a design flaw that will be fixed eventually. There's a

Re: Rewrite of std.range docs (Was: Re: Making sense of ranges)

2012-03-27 Thread H. S. Teoh
On Tue, Mar 27, 2012 at 09:55:43PM +0900, Mike Parker wrote: > On 3/27/2012 7:26 PM, Marco Leise wrote: [...] > >"Ranges whose elements are sorted affords ..."<- insert a comma > >before affords perhaps? It would help non-native speakers. > > > > Actually, a comma there would be incorrect. But bec

Re: Problem about lambda expressions

2012-03-27 Thread dennis luehring
Am 27.03.2012 15:52, schrieb Tongzhou Li: Oh, I also tried: void seq_apply(Params..., Args...)(void delegate(Params) func, Args args) But I got a error: variadic template parameter must be last Does it mean that there can only be one variadic template parameter? How to fix it? Thanks

Re: Problem with receiveOnly and classes

2012-03-27 Thread kraybourne
On 3/25/12 19:33 , Ghislain wrote: Hello, [...] I do not understand why an object of type A is fetched as a Variant, while a object of type B is received correctly. [...] Any idea? Hi! I get the same on Mac DMD 2.058. I have no idea. Looks like a bug to me, although I can't say which part i

Re: Problem about lambda expressions

2012-03-27 Thread Tongzhou Li
Oh, I also tried: void seq_apply(Params..., Args...)(void delegate(Params) func, Args args) But I got a error: variadic template parameter must be last Does it mean that there can only be one variadic template parameter? How to fix it? Thanks

Re: Installing x32 packages on x64 debian (or fix a dmd bug)

2012-03-27 Thread simendsjo
On Tue, 27 Mar 2012 15:11:38 +0200, Jordi Sayol wrote: Al 27/03/12 15:03, En/na simendsjo ha escrit: I have ia32-libs, but say I want to install mysql? I can only get x64 versions thourgh the package manager. Trying to download and install 32-bit .deps says it's conflicting with the insta

Problem about lambda expressions

2012-03-27 Thread Tongzhou Li
Hello again! I'm learning D, and I encountered a problem. I tried this code: http://ideone.com/hkpT6 It works well. (Have no idea why codepad.org failed to compile it) I tried to write a lambda instead of function f, but I got nothing printed. Did I make something wrong? Compiler used: DMD32 D C

Re: Printing stacktrace on segfault

2012-03-27 Thread David
Am 27.03.2012 12:04, schrieb simendsjo: Is there a way to print a stacktrace on segfaults on linux? I haven't found one, but you can use gdb, the only thing you've to do is to compile with -g and -gc (or you use gdc)

Re: Installing x32 packages on x64 debian (or fix a dmd bug)

2012-03-27 Thread Jordi Sayol
Al 27/03/12 15:03, En/na simendsjo ha escrit: > On Tue, 27 Mar 2012 13:24:06 +0200, Jordi Sayol wrote: > >> Al 27/03/12 12:40, En/na simendsjo ha escrit: >>> On Tue, 27 Mar 2012 12:18:45 +0200, Jordi Sayol wrote: >>> Al 27/03/12 11:52, En/na simendsjo ha escrit: > This might not be the

Re: GUI library

2012-03-27 Thread Tyro[17]
On Sunday, 25 March 2012 at 15:59:21 UTC, Jacob Carlborg wrote: On 2012-03-25 17:22, Kevin Cox wrote: I would reccomend Qt as well. You will get native cross-platform widgets with great performance. I am not sure how far QtD is but I know it once had a lot of development on it. I don't thi

Re: Installing x32 packages on x64 debian (or fix a dmd bug)

2012-03-27 Thread simendsjo
On Tue, 27 Mar 2012 13:24:06 +0200, Jordi Sayol wrote: Al 27/03/12 12:40, En/na simendsjo ha escrit: On Tue, 27 Mar 2012 12:18:45 +0200, Jordi Sayol wrote: Al 27/03/12 11:52, En/na simendsjo ha escrit: This might not be the best forum to ask, but as it relates a dmd bug, I hope others h

Re: Rewrite of std.range docs (Was: Re: Making sense of ranges)

2012-03-27 Thread Mike Parker
On 3/27/2012 7:26 PM, Marco Leise wrote: Am Tue, 27 Mar 2012 06:00:58 +0200 schrieb "Jesse Phillips": On Monday, 26 March 2012 at 00:50:32 UTC, H. S. Teoh wrote: This thread has further convinced me that std.range's docs *need* this rewrite. So here's my first attempt at it: https://

Re: std.stream.File help required (and classes)

2012-03-27 Thread akaz
I should at that the "__gshared" attribute was added in distress, but changed nothing. With or without it, the program still crashes.

std.stream.File help required (and classes)

2012-03-27 Thread akaz
Hi all, I am trying to port some application based on a library called mediastreamer2, part of linphone software. The basic software component built on top of mediastreamer2 is called a "filter". Basically, it is a C structure with parameters and some methods (pointers to functions). Am

Re: Rewrite of std.range docs (Was: Re: Making sense of ranges)

2012-03-27 Thread Marco Leise
Am Tue, 27 Mar 2012 06:00:58 +0200 schrieb "Jesse Phillips" : > On Monday, 26 March 2012 at 00:50:32 UTC, H. S. Teoh wrote: > > > This thread has further convinced me that std.range's docs > > *need* this > > rewrite. So here's my first attempt at it: > > > > https://github.com/quickfur/phob

Re: Installing x32 packages on x64 debian (or fix a dmd bug)

2012-03-27 Thread Jordi Sayol
Al 27/03/12 12:40, En/na simendsjo ha escrit: > On Tue, 27 Mar 2012 12:18:45 +0200, Jordi Sayol wrote: > >> Al 27/03/12 11:52, En/na simendsjo ha escrit: >>> This might not be the best forum to ask, but as it relates a dmd bug, I >>> hope others here have found a workaround. >>> >>> I'm using a

Re: Installing x32 packages on x64 debian (or fix a dmd bug)

2012-03-27 Thread simendsjo
On Tue, 27 Mar 2012 12:18:45 +0200, Jordi Sayol wrote: Al 27/03/12 11:52, En/na simendsjo ha escrit: This might not be the best forum to ask, but as it relates a dmd bug, I hope others here have found a workaround. I'm using a debian-based x64 distro. Due to http://d.puremagic.com/issues/

Re: Installing x32 packages on x64 debian (or fix a dmd bug)

2012-03-27 Thread Jordi Sayol
Al 27/03/12 11:52, En/na simendsjo ha escrit: > This might not be the best forum to ask, but as it relates a dmd bug, I hope > others here have found a workaround. > > I'm using a debian-based x64 distro. Due to > http://d.puremagic.com/issues/show_bug.cgi?id=5570, I have to compile for > -m32.

Printing stacktrace on segfault

2012-03-27 Thread simendsjo
Is there a way to print a stacktrace on segfaults on linux?

Installing x32 packages on x64 debian (or fix a dmd bug)

2012-03-27 Thread simendsjo
This might not be the best forum to ask, but as it relates a dmd bug, I hope others here have found a workaround. I'm using a debian-based x64 distro. Due to http://d.puremagic.com/issues/show_bug.cgi?id=5570, I have to compile for -m32. The challenge is installing 32-bit libraries using ap