Re: Redundant "g" flag for regex?

2018-06-23 Thread biocyberman via Digitalmars-d-learn
On Saturday, 23 June 2018 at 13:45:32 UTC, Basile B. wrote: On Saturday, 23 June 2018 at 12:17:08 UTC, biocyberman wrote: I get the same output with or without "g" flag at line 6: https://run.dlang.io/is/9n7iz6 So I don't understand when I have to use "g" flag. My bet is that Regex results

Re: why explicitly use "flags" in regex does not work?

2018-06-23 Thread biocyberman via Digitalmars-d-learn
On Saturday, 23 June 2018 at 12:20:10 UTC, biocyberman wrote: I got "Error: undefined identifier flags" in here: https://run.dlang.io/is/wquscz Removing "flags =" works. I kinda found an answer. It's a bit of a surprise anyway:

why explicitly use "flags" in regex does not work?

2018-06-23 Thread biocyberman via Digitalmars-d-learn
I got "Error: undefined identifier flags" in here: https://run.dlang.io/is/wquscz Removing "flags =" works.

Redundant "g" flag for regex?

2018-06-23 Thread biocyberman via Digitalmars-d-learn
I get the same output with or without "g" flag at line 6: https://run.dlang.io/is/9n7iz6 So I don't understand when I have to use "g" flag.

Re: Convert a huge SQL file to CSV

2018-06-03 Thread biocyberman via Digitalmars-d-learn
On Friday, 1 June 2018 at 10:15:11 UTC, Martin Tschierschke wrote: On Friday, 1 June 2018 at 09:49:23 UTC, biocyberman wrote: I need to convert a compressed 17GB SQL dump to CSV. A workable solution is to create a temporary mysql database, import the dump, query by python, and export. But i

Convert a huge SQL file to CSV

2018-06-01 Thread biocyberman via Digitalmars-d-learn
I need to convert a compressed 17GB SQL dump to CSV. A workable solution is to create a temporary mysql database, import the dump, query by python, and export. But i wonder if there is something someway in D to parse the SQL file directly and query and export the data. I imagine this will

Re: Logging inside struct?

2018-05-30 Thread biocyberman via Digitalmars-d-learn
On Wednesday, 30 May 2018 at 10:07:35 UTC, Simen Kjærås wrote: On Wednesday, 30 May 2018 at 09:58:16 UTC, biocyberman wrote: [...] This line: writeln("got num: %s, of type: %s", num, typeof(num)); [...] Problem solved. Thanks Simen!

Logging inside struct?

2018-05-30 Thread biocyberman via Digitalmars-d-learn
How do I add logging for this struct? https://run.dlang.io/is/9N6N4o If not possible, what's the alternative?

Re: Translate C/C++ patern: return a pointer

2018-05-26 Thread biocyberman via Digitalmars-d-learn
On Thursday, 24 May 2018 at 17:44:19 UTC, Jacob Carlborg wrote: On 2018-05-24 11:10, biocyberman wrote: Thanks for the hints. `Read` in C++ and D are both classes. And the function is inside the class definition itself. In that case specifying the type as `Read` is the correct thing to do.

Re: return type of std.algorithm.mutation.reverse changed for good?

2018-05-24 Thread biocyberman via Digitalmars-d-learn
On Thursday, 24 May 2018 at 12:34:38 UTC, Steven Schveighoffer wrote: On 5/24/18 8:08 AM, rikki cattermole wrote: On 25/05/2018 12:06 AM, biocyberman wrote: I am testing with DMD 2.078.2 locally. This tiny snippet works on dlang's online editor: https://run.dlang.io/is/nb4IV4 But it does not

return type of std.algorithm.mutation.reverse changed for good?

2018-05-24 Thread biocyberman via Digitalmars-d-learn
I am testing with DMD 2.078.2 locally. This tiny snippet works on dlang's online editor: https://run.dlang.io/is/nb4IV4 But it does not work on my local dmd. import std.algorithm.mutation; import std.stdio; char[] arr = "hello\U00010143\u0100\U00010143".dup; writeln(arr.reverse); Error:

Re: Translate C/C++ patern: return a pointer

2018-05-24 Thread biocyberman via Digitalmars-d-learn
On Thursday, 24 May 2018 at 08:58:02 UTC, Nicholas Wilson wrote: On Thursday, 24 May 2018 at 08:16:30 UTC, biocyberman wrote: [...] it looks like Read is a D class? in which case it already returns by reference. If you make Read a struct then all you need do is change the function signature

Re: Efficient idiom for fastest code

2018-05-24 Thread biocyberman via Digitalmars-d-learn
On Wednesday, 23 May 2018 at 03:12:52 UTC, IntegratedDimensions wrote: On Wednesday, 23 May 2018 at 03:00:17 UTC, Nicholas Wilson wrote: [...] I knew someone was going to say that and I forgot to say DON'T! Saying to profile when I clearly said these ARE cases where they are slow is just

Translate C/C++ patern: return a pointer

2018-05-24 Thread biocyberman via Digitalmars-d-learn
Some C and C++ projects I am working on use pointers and references extensively: to pass as function arguments, and to return from a function. For function argument I would use `ref`, but for return types, I can't use `ref` and can't return a pointer. What should be the proper way to handle

Re: Coding Challenges at Dconf2018: Implement Needleman–Wunsch and Smith–Waterman algorithms

2018-05-04 Thread biocyberman via Digitalmars-d-learn
On Friday, 4 May 2018 at 14:13:19 UTC, Luís Marques wrote: On Monday, 30 April 2018 at 18:47:21 UTC, biocyberman wrote: I am attending Dconf 2018 and giving a talk there on May 4. Link: https://dconf.org/2018/talks/le.html. It will be very interesting to talk about the outcome of the following

Re: Coding Challenges at Dconf2018: Implement Needleman–Wunsch and Smith–Waterman algorithms

2018-05-01 Thread biocyberman via Digitalmars-d-learn
On Monday, 30 April 2018 at 20:34:41 UTC, Steven Schveighoffer wrote: On 4/30/18 2:47 PM, biocyberman wrote: Hellow D community. I am attending Dconf 2018 and giving a talk there on May 4. Link: https://dconf.org/2018/talks/le.html. It will be very interesting to talk about the outcome of

Coding Challenges at Dconf2018: Implement Needleman–Wunsch and Smith–Waterman algorithms

2018-04-30 Thread biocyberman via Digitalmars-d-learn
Hellow D community. I am attending Dconf 2018 and giving a talk there on May 4. Link: https://dconf.org/2018/talks/le.html. It will be very interesting to talk about the outcome of the following challenges. If we can't have at least 3 solutions by three individuals by 10:00 GMT+2 May 4, I

Re: Tuts/Aritcles: Incrementasl C++-to-D conversion?

2018-02-23 Thread biocyberman via Digitalmars-d-learn
On Thursday, 22 February 2018 at 08:43:24 UTC, ketmar wrote: Nick Sabalausky (Abscissa) wrote: [...] from my experience (various codebases up to middle size, mostly C, some C++): fsck the "one module at a time" idea! even in D modules are interwined, and in C and C++ they're even more so.

check mountpoint status and send email on timeout/failure?

2017-12-11 Thread biocyberman via Digitalmars-d-learn
For someone using NFS or some other remote filesystems, one may have experienced many times the nasty silent hang. For example, if I run `ls /mnt/remote/nfsmount`, and the remote NFS server is down while /mnt/remote/nfsmount was mounted, it will take very long time or forever for the `ls`

Re: fasta parser with iopipe?

2017-08-28 Thread biocyberman via Digitalmars-d-learn
On Wednesday, 23 August 2017 at 13:06:36 UTC, Steven Schveighoffer wrote: On 8/23/17 5:53 AM, biocyberman wrote: [...] I'll respond to all your questions with what I would do, instead of answering each one. I would suggest an approach similar to how I approached parsing JSON data. In your

fasta parser with iopipe?

2017-08-23 Thread biocyberman via Digitalmars-d-learn
I lost my momentum to learn D and want to gain it up again. Therefore I need some help with this seemingly simple task: # Fasta sequence \>Entry1_ID header field1|header field2|... CAGATATCTTTGATGTCCTGATTGGAAGGACCGTTGGCCACCCTTAGGCAG TGTATACTCTTCCATAAACGAGCTATTAGTTATGAGGTCCGTAGATTGGGG

Lazy range, extract only Nth element, set range size constraint?

2017-07-09 Thread biocyberman via Digitalmars-d-learn
Following is the code for a more generalized Fibonacci range. Questions: 1. How do I get only the value of the Nth (i.e. N = 25) element in an idiomatic way? 2. Can I set constraints in the range so that user gets warning if he asks for Nth element greater than a limit, say N> 30; or if

Re: Which editor to use for editing DDOCs?

2017-07-07 Thread biocyberman via Digitalmars-d-learn
On Tuesday, 23 May 2017 at 10:10:24 UTC, Russel Winder wrote: On Tue, 2017-05-23 at 07:40 +, biocyberman via Digitalmars-d-learn wrote: […] Adding DDOC support for D Mode require some more work obviously. I will see if I can make some changes to that. For the time being, I would like

Re: Which editor to use for editing DDOCs?

2017-05-23 Thread biocyberman via Digitalmars-d-learn
On Monday, 22 May 2017 at 15:33:36 UTC, Russel Winder wrote: On Mon, 2017-05-22 at 14:14 +, biocyberman via Digitalmars-d-learn wrote: Which one do you use? I am using Linux and Emacs for editing other D source file. But the DDOC syntaxes and keywords are not well high-lighted. There has

Which editor to use for editing DDOCs?

2017-05-22 Thread biocyberman via Digitalmars-d-learn
Which one do you use? I am using Linux and Emacs for editing other D source file. But the DDOC syntaxes and keywords are not well high-lighted.

Re: [OT] #define

2017-05-22 Thread biocyberman via Digitalmars-d-learn
On Monday, 22 May 2017 at 13:11:15 UTC, Andrew Edwards wrote: Sorry if this is a stupid question but it eludes me. In the following, what is THING? What is SOME_THING? #ifndef THING #define THING #endif #ifndef SOME_THING #define SOME_THING THING * #endif Is this

Re: Code improvement for DNA reverse complement?

2017-05-22 Thread biocyberman via Digitalmars-d-learn
On Monday, 22 May 2017 at 10:35:36 UTC, ag0aep6g wrote: On 05/22/2017 10:58 AM, biocyberman wrote: [...] For reference, here is the version of revComp3 I commented on: string revComp3(string bps) { const N = bps.length; enum chars = [Repeat!('A'-'\0', '\0'), 'T',

Re: Code improvement for DNA reverse complement?

2017-05-22 Thread biocyberman via Digitalmars-d-learn
On Monday, 22 May 2017 at 06:50:45 UTC, Biotronic wrote: On Friday, 19 May 2017 at 22:53:39 UTC, crimaniak wrote: On Friday, 19 May 2017 at 12:55:05 UTC, Biotronic wrote: revComp6 seems to be the fastest, but it's probably also the least readable (a common trade-off). Try revComp7 with

Re: Code improvement for DNA reverse complement?

2017-05-19 Thread biocyberman via Digitalmars-d-learn
On Friday, 19 May 2017 at 09:17:04 UTC, Biotronic wrote: On Friday, 19 May 2017 at 07:29:44 UTC, biocyberman wrote: [...] Question about your implementation: you assume the input may contain newlines, but don't handle any other non-ACGT characters. The problem definition states 'DNA string'

Re: Code improvement for DNA reverse complement?

2017-05-19 Thread biocyberman via Digitalmars-d-learn
On Friday, 19 May 2017 at 07:46:13 UTC, Stefan Koch wrote: On Friday, 19 May 2017 at 07:29:44 UTC, biocyberman wrote: I am solving this problem http://rosalind.info/problems/revc/ as an exercise to learn D. This is my solution: https://dpaste.dzfl.pl/8aa667f962b7 Is there some D tricks I can

Code improvement for DNA reverse complement?

2017-05-19 Thread biocyberman via Digitalmars-d-learn
I am solving this problem http://rosalind.info/problems/revc/ as an exercise to learn D. This is my solution: https://dpaste.dzfl.pl/8aa667f962b7 Is there some D tricks I can use to make the `reverseComplement` function more concise and speedy? Any other comments for improvement of the whole

Re: Fails to use testFilename in unittest

2017-05-18 Thread biocyberman via Digitalmars-d-learn
On Thursday, 18 May 2017 at 10:05:41 UTC, Jonathan M Davis wrote: On Thursday, May 18, 2017 09:56:36 biocyberman via Digitalmars-d-learn wrote: [...] My point is that it's a private function for testing std.stdio and not intended to be part of the public API or be used by anyone else (it's

Re: Fails to use testFilename in unittest

2017-05-18 Thread biocyberman via Digitalmars-d-learn
On Thursday, 18 May 2017 at 09:49:26 UTC, Jonathan M Davis wrote: On Thursday, May 18, 2017 09:40:33 biocyberman via Digitalmars-d-learn wrote: [...] Actually, it's not used all over the place in Phobos. It's only used std.stdio, where it's a private function in a version(unittest) block

Re: Fails to use testFilename in unittest

2017-05-18 Thread biocyberman via Digitalmars-d-learn
This is the compile error message by the way: dmd -unittest ./testFile.d

Fails to use testFilename in unittest

2017-05-18 Thread biocyberman via Digitalmars-d-learn
There is a ongoing discussion about temp file over here: http://forum.dlang.org/thread/sbehcxusxxibmpkae...@forum.dlang.org I have a question about generating a temporary file to write test data. I can create my own file and use it but just want to use the existing tool for convenience.

Re: How to move append to an array?

2017-05-18 Thread biocyberman via Digitalmars-d-learn
On Monday, 15 May 2017 at 21:38:52 UTC, Yuxuan Shui wrote: Suppose I have a struct A { @disable this(this); } x; How do I append it into an array? Do I have to do array.length++; moveEmplace(x, array[$-1]); ? Judging form the way you write the struct. It is of C/C++ style. With that

Re: Convert this C macro kroundup32 to D mixin?

2017-04-09 Thread biocyberman via Digitalmars-d-learn
On Saturday, 8 April 2017 at 21:34:30 UTC, Ali Çehreli wrote: You can mixin declarations with a template but I don't see how it can help here. A string mixin would work but it's really ugly at the use site: string roundUp(alias x)() if (is (typeof(x) == uint)) { import std.string :

Re: Convert this C macro kroundup32 to D mixin?

2017-04-08 Thread biocyberman via Digitalmars-d-learn
On Saturday, 8 April 2017 at 11:24:02 UTC, Nicholas Wilson wrote: The ':' means that it applies to everything that follows it, so while it doesn't matters in this example if you had pragma( inline, true ): int kroundup32( int x) { ... } auto someVeryLargeFunction( Args args) { // ... }

Re: Convert this C macro kroundup32 to D mixin?

2017-04-08 Thread biocyberman via Digitalmars-d-learn
On Saturday, 8 April 2017 at 10:09:47 UTC, Mike Parker wrote: T kroundup32(T)(T x) { pragma(inline, true); --(x); (x)|=(x)>>1; (x)|=(x)>>2; (x)|=(x)>>4; (x)|=(x)>>8; (x)|=(x)>>16; return ++(x); } I also came up with this: import std.stdio; pragma( inline, true

Re: Convert this C macro kroundup32 to D mixin?

2017-04-08 Thread biocyberman via Digitalmars-d-learn
On Saturday, 8 April 2017 at 10:02:01 UTC, Mike Parker wrote: I would expect if you implement it as a function the compiler will inline it. You can always use the pragma(inline, true) [1] with -inline to verify. [1] https://dlang.org/spec/pragma.html#inline Thanks for mentioning pragma.

Convert this C macro kroundup32 to D mixin?

2017-04-08 Thread biocyberman via Digitalmars-d-learn
What is the D mixin version equivalent to this macro: #define kroundup32(x) (--(x), (x)|=(x)>>1, (x)|=(x)>>2, (x)|=(x)>>4, (x)|=(x)>>8, (x)|=(x)>>16, ++(x)) The macro looks cryptic. What the macro does has been explained here:

Re: Using template mixin, with or without mixin ?

2017-04-08 Thread biocyberman via Digitalmars-d-learn
On Friday, 7 April 2017 at 23:53:12 UTC, Ali Çehreli wrote: The difference is that you can't use funcgen as a regular template: funcgen!(void, void); Error: template instance funcgen!(void, void) mixin templates are not regular templates I think it's good practice to use 'mixin

Using template mixin, with or without mixin ?

2017-04-07 Thread biocyberman via Digitalmars-d-learn
I want to use mixin to generate function in-place. In template declaration, I can see 'mixin' keyword is optional. Is it true? What is the difference and when I must use one way over another? This is my program: // This works with and without 'mixin' attribute. mixin template funcgen(T, U){

Re: Covert a complex C header to D

2017-04-05 Thread biocyberman via Digitalmars-d-learn
On Monday, 3 April 2017 at 23:10:49 UTC, Stefan Koch wrote: On Monday, 3 April 2017 at 11:18:21 UTC, Nicholas Wilson wrote: prefer template over string mixins where possible. This will make the code much more readable. My advise would be the opposite. templates put much more pressure on

Re: OT: It is convert, not covert

2017-04-04 Thread biocyberman via Digitalmars-d-learn
On Tuesday, 4 April 2017 at 05:29:42 UTC, Ali Çehreli wrote: Covert has a very different meaning. :) Ali Thanks Ali. My fingers argued they are the same :) And I can't find a way to edit my post after posting. I would love to have your input. I am revisited your book several times to

Re: Covert a complex C header to D

2017-04-03 Thread biocyberman via Digitalmars-d-learn
On Monday, 3 April 2017 at 00:00:04 UTC, Nicholas Wilson wrote: On Sunday, 2 April 2017 at 21:43:52 UTC, biocyberman wrote: template __KHASH_TYPE(string name){ "struct kh_" ~ name ~"_t { " ~ "khint_t n_buckets, size, n_occupied, upper_bound; " ~ "khint32_t

Covert a complex C header to D

2017-04-02 Thread biocyberman via Digitalmars-d-learn
khash.h (http://attractivechaos.github.io/klib/#Khash%3A%20generic%20hash%20table) is a part of klib library in C. I want to covert it to D in the process of learning deeper about D. First I tried with Dstep (https://github.com/jacob-carlborg/dstep) and read the C to D article

Re: high performance client server solution in D?

2017-03-23 Thread biocyberman via Digitalmars-d-learn
@Laeeth Isharc and rikki cattermole: Thank you for your inputs. Msgpack is definitely something I will consider. I tried search some show cases and open-source projects of this kind for Dlang but still haven't found one. Those applications will give clearer ideas.

high performance client server solution in D?

2017-03-23 Thread biocyberman via Digitalmars-d-learn
I am considering to use D and its library to build a high performance client-server application. The client will be a cross platform (Windows, Mac, Linux) GUI program that can synchronize analysis results with the remote central server, and analyze data locally. It will also visualize big data

Re: Is it possbile to specify a remote git repo as dub dependency?

2016-12-20 Thread biocyberman via Digitalmars-d-learn
On Monday, 19 December 2016 at 16:23:45 UTC, Guillaume Piolat wrote: What you can do for private package as of today is: - use path-based dependencies and put your packages in the same repo - use git submodules and path-based dub dependencies together If it's a public package, you can

Re: Is it possbile to specify a remote git repo as dub dependency?

2016-12-19 Thread biocyberman via Digitalmars-d-learn
On Monday, 19 December 2016 at 14:18:17 UTC, Jacob Carlborg wrote: On 2016-12-19 13:11, biocyberman wrote: I can write a short script to clone the remote git repo and use it as a submodule. But if it is possible to do with dub, it will be more convenient. It's not currently possible. I

Is it possbile to specify a remote git repo as dub dependency?

2016-12-19 Thread biocyberman via Digitalmars-d-learn
I can write a short script to clone the remote git repo and use it as a submodule. But if it is possible to do with dub, it will be more convenient.