Re: Orphan format arguments: args[0..1]

2018-12-16 Thread bauss via Digitalmars-d-learn
On Sunday, 16 December 2018 at 00:34:48 UTC, Ali Çehreli wrote: This one confused me until I decided to talk to a rubber ducky: import std.string; void main() { auto s = "%s is a good number".format(42); } Fine; it works... Then the string becomes too long and I split it:

Orphan format arguments: args[0..1]

2018-12-15 Thread Ali Çehreli via Digitalmars-d-learn
This one confused me until I decided to talk to a rubber ducky: import std.string; void main() { auto s = "%s is a good number".format(42); } Fine; it works... Then the string becomes too long and I split it: auto s = "%s is a good number but one needs to know" ~

Re: What can I use to parse a date string in a custom format?

2018-11-27 Thread Neia Neutuladh via Digitalmars-d-learn
On Tue, 27 Nov 2018 18:22:17 +, PacMan wrote: > I've been looking for a function or library to parse a date in a custom > format (for validation) similar to C#'s [1] > TryParseExactbut I couldn't find any. so far I only found > fromISOExtString(), and fromSimpleString() which does

What can I use to parse a date string in a custom format?

2018-11-27 Thread PacMan via Digitalmars-d-learn
I've been looking for a function or library to parse a date in a custom format (for validation) similar to C#'s [1] TryParseExactbut I couldn't find any. so far I only found fromISOExtString(), and fromSimpleString() which doesn't allow me to set a custom string format. I've looked up

Re: expanding variadic into format

2018-10-31 Thread Codifies via Digitalmars-d-learn
On Wednesday, 31 October 2018 at 12:54:52 UTC, Stanislav Blinov wrote: On Wednesday, 31 October 2018 at 12:13:57 UTC, Codifies wrote: [...] [...] As rikki already explained, std.format is a variadic template, which gets expanded into argument list at compile time. That's why it can't be

Re: expanding variadic into format

2018-10-31 Thread Stanislav Blinov via Digitalmars-d-learn
message = format(frmt, forward!args); // ... } ``` thats fantastic thanks so much, can you explain a little more about whats going on here ? As rikki already explained, std.format is a variadic template, which gets expanded into argument list at compile time. That's why it can't be used with C

Re: expanding variadic into format

2018-10-31 Thread rikki cattermole via Digitalmars-d-learn
On 01/11/2018 1:08 AM, Codifies wrote: On Wednesday, 31 October 2018 at 11:56:31 UTC, rikki cattermole wrote: On 01/11/2018 12:53 AM, Codifies wrote: [...] Just to confirm, format there is std.format:format right? Because that isn't using C variadics, its using template variadics. thought

Re: expanding variadic into format

2018-10-31 Thread Codifies via Digitalmars-d-learn
On Wednesday, 31 October 2018 at 12:09:04 UTC, Stanislav Blinov wrote: On Wednesday, 31 October 2018 at 11:53:52 UTC, Codifies wrote: void printValue(Font fnt,float x, float y, string frmt, ...) { /* matrix math and other stuff removed for readability */ string message = format(frmt

Re: expanding variadic into format

2018-10-31 Thread Codifies via Digitalmars-d-learn
On Wednesday, 31 October 2018 at 11:56:31 UTC, rikki cattermole wrote: On 01/11/2018 12:53 AM, Codifies wrote: [...] Just to confirm, format there is std.format:format right? Because that isn't using C variadics, its using template variadics. thought I was using core.vararg and std.format

Re: expanding variadic into format

2018-10-31 Thread Stanislav Blinov via Digitalmars-d-learn
On Wednesday, 31 October 2018 at 11:53:52 UTC, Codifies wrote: void printValue(Font fnt,float x, float y, string frmt, ...) { /* matrix math and other stuff removed for readability */ string message = format(frmt, _arguments); is there some way to somehow transfer my input variadic

Re: expanding variadic into format

2018-10-31 Thread rikki cattermole via Digitalmars-d-learn
, ...) {     /* matrix math and other stuff removed for readability */     string message = format(frmt, _arguments); no surprise this naive attempt causes a runtime error as its trying to format a range using the first format specifier in frmt am I going to have to chop frmt into descrete chunks

expanding variadic into format

2018-10-31 Thread Codifies via Digitalmars-d-learn
removed for readability */ string message = format(frmt, _arguments); no surprise this naive attempt causes a runtime error as its trying to format a range using the first format specifier in frmt am I going to have to chop frmt into descrete chunks that have just one % symbol in them

Re: Dynamic Minimum width with Format / writefln

2018-10-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 01:14:24 UTC, Chris Katko wrote: I'm not sure how I made this mistake. But it seems to only show up now if I leave .toStringz() with the writefln. Yeah. So what's happening here is toStringz returns the C-style char*, which printf works well with, but writef

Re: Dynamic Minimum width with Format / writefln

2018-10-02 Thread Chris Katko via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 00:34:33 UTC, Adam D. Ruppe wrote: On Wednesday, 3 October 2018 at 00:14:03 UTC, Chris Katko wrote: Except it doesn't work and tries to decode col.width-1 into a hexadecimal number and only prints that. ("4D6EF6") That number certainly isn't col.width (unless

Re: Dynamic Minimum width with Format / writefln

2018-10-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 00:14:03 UTC, Chris Katko wrote: Except it doesn't work and tries to decode col.width-1 into a hexadecimal number and only prints that. ("4D6EF6") That number certainly isn't col.width (unless you have a width of like millions)... It looks more like a

Dynamic Minimum width with Format / writefln

2018-10-02 Thread Chris Katko via Digitalmars-d-learn
This works fine in D: printf("%-*s|", col.width-1, col.name.toStringz()); It's a left-aligned, string with a minimum width from the first argument, col.width. (-1 because I'm throwing a pipe symbol on the end.) Now with writefln: writefln("%-*s|", col.width-1, col

Re: "%s"-format template function arguments

2018-04-15 Thread ag0aep6g via Digitalmars-d-learn
T)(T[] args ...) { writefln("%s", args); } [...] P.S. I do not understand why only a `1` is printed in the actual result. This: writefln("actual: %s", args); becomes this: writefln("actual: %s", args[0], args[1], args[2]); So th

Re: "%s"-format template function arguments

2018-04-15 Thread Dennis via Digitalmars-d-learn
On Sunday, 15 April 2018 at 12:04:19 UTC, vladdeSV wrote: How would I go on about to print all the arguments as I expected it, using "%s"? You can expand the template arguments into an array by putting it into square brackets: [args]. You can format an array with the default nota

Re: "%s"-format template function arguments

2018-04-15 Thread Alex via Digitalmars-d-learn
On Sunday, 15 April 2018 at 12:04:19 UTC, vladdeSV wrote: Hello people of D-land. In a template function, I want to format all arguments as if it was an array. Se this snippet of code: foo(1,2,3); void foo(T...)(T args) { writefln("expected: %s&quo

"%s"-format template function arguments

2018-04-15 Thread vladdeSV via Digitalmars-d-learn
Hello people of D-land. In a template function, I want to format all arguments as if it was an array. Se this snippet of code: foo(1,2,3); void foo(T...)(T args) { writefln("expected: %s", [1,2,3]); writefln("actual: %s", args); } The co

Re: compile-time checked format strings

2018-01-13 Thread kdevel via Digitalmars-d-learn
%2.2d %2.2d" (1); // OK: Orphan format specifier //writefln!"%2.2d" (1, 2); // OK: Orphan format arguments: } ```

Re: compile-time checked format strings

2018-01-13 Thread Basile B. via Digitalmars-d-learn
On Saturday, 13 January 2018 at 19:40:09 UTC, Adam D. Ruppe wrote: On Saturday, 13 January 2018 at 19:15:49 UTC, kdevel wrote: dmd checks the types but does not count the arguments. so note that dmd doesn't actually do any checks here - it is all done in library code. The implementation is

Re: compile-time checked format strings

2018-01-13 Thread Adam D. Ruppe via Digitalmars-d-learn
/format.d#L5803 try format(...) catch(Exception) trigger compile time error. But, since float format doesn't work at compile time, this method doesn't actually work to catch any float-related problems except mismatching format characters! For ints, it catches all that, but for float, it just

compile-time checked format strings

2018-01-13 Thread kdevel via Digitalmars-d-learn
* atan (T (1)); writefln!"%30.24f" (pi, pi); // no error! writefln!"%30.24f %30.24f" (pi, pi); // OK // writefln!"%30.24d %30.24f" (pi, pi); // OK: "incompatible format character writefln!"%30.24f %30.24f %30.24f" (pi, pi); // no error

Re: Problem with std.string.strip(): Can't use result in format routine

2017-09-05 Thread Ky-Anh Huynh via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 13:56:20 UTC, Andrea Fontana wrote: I used `lines(stdin)` as in https://dlang.org/phobos/std_stdio.html#.lines . My source code is here https://github.com/icy/dusybox/blob/master/src/plotbar/main.d#L47 . Thanks for your support. I think formattedRead is

Re: Problem with std.string.strip(): Can't use result in format routine

2017-09-05 Thread Andrea Fontana via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 13:40:18 UTC, Ky-Anh Huynh wrote: On Tuesday, 5 September 2017 at 13:17:34 UTC, Azi Hassan wrote: Maybe it has something to do with how you read from STDIN. Can you show that part of the code to see if I can reproduce the issue ? I used `lines(stdin)` as in

Re: Problem with std.string.strip(): Can't use result in format routine

2017-09-05 Thread Ky-Anh Huynh via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 13:17:34 UTC, Azi Hassan wrote: Maybe it has something to do with how you read from STDIN. Can you show that part of the code to see if I can reproduce the issue ? I used `lines(stdin)` as in https://dlang.org/phobos/std_stdio.html#.lines . My source code

Re: Problem with std.string.strip(): Can't use result in format routine

2017-09-05 Thread Azi Hassan via Digitalmars-d-learn
On Tuesday, 5 September 2017 at 12:38:54 UTC, Ky-Anh Huynh wrote: Hi, I read line from STDIN , and strip them [code] auto line_st = line.strip(); [/code] However, I can't use result in another format routine. Assume my input line is "foobar": [code] writeln("Stripped line

Problem with std.string.strip(): Can't use result in format routine

2017-09-05 Thread Ky-Anh Huynh via Digitalmars-d-learn
Hi, I read line from STDIN , and strip them [code] auto line_st = line.strip(); [/code] However, I can't use result in another format routine. Assume my input line is "foobar": [code] writeln("Stripped line is %s", line_st); [/code] This code only prints "Str

Re: Multi dimensional array format priting

2017-08-25 Thread Vino.B via Digitalmars-d-learn
On Friday, 25 August 2017 at 17:41:31 UTC, Vino.B wrote: On Friday, 25 August 2017 at 17:02:53 UTC, Jonathan M Davis wrote: On Friday, August 25, 2017 16:45:16 Vino.B via Digitalmars-d-learn wrote: Hi, Request your help on the below issue, Issue : While appending data to a array the data

Re: wth!! ctfe cannot format floating point at compile time?

2017-08-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 14 August 2017 at 13:11:20 UTC, Steven Schveighoffer wrote: Another reasonable idea is to have the compiler call the function for you. Yeah, I was thinking that too. Heck, the compiler prolly uses it for reading source and writing errors. Perhaps just special case hack the

Re: wth!! ctfe cannot format floating point at compile time?

2017-08-14 Thread Steven Schveighoffer via Digitalmars-d-learn
the compiler only ever exists on platforms with libc available, the libc function is available to the compiler too. having some special intrinsic to format floating points wouldn't be out of the question. It is quite limiting to have floating point string conversions not available. -Steve

Re: wth!! ctfe cannot format floating point at compile time?

2017-08-14 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 14 August 2017 at 04:29:17 UTC, Johnson wrote: ``` auto valueToString(alias v)(){return v.stringof;} enum a = valueToString!(0.75); static assert(a == "0.75"); ``` Thanks! You'd think that to would do this internally automatically ;/ It only works on literals. valueToString!(a)

Re: wth!! ctfe cannot format floating point at compile time?

2017-08-13 Thread Johnson via Digitalmars-d-learn
On Monday, 14 August 2017 at 03:52:40 UTC, HypperParrow wrote: On Monday, 14 August 2017 at 01:52:16 UTC, Johnson Jones wrote: Error: uncaught CTFE exception std.format.FormatException("Cannot format floating point types at compile-time") called from here: to(0.75) pretty simp

Re: wth!! ctfe cannot format floating point at compile time?

2017-08-13 Thread Johnson via Digitalmars-d-learn
On Monday, 14 August 2017 at 03:44:27 UTC, Adam D. Ruppe wrote: On Monday, 14 August 2017 at 01:52:16 UTC, Johnson Jones wrote: pretty simply, trying to convert a floating point to a string in a ctfe function and it thinks that it is too complex to do in a ctfe, really? It uses a C function

Re: wth!! ctfe cannot format floating point at compile time?

2017-08-13 Thread HypperParrow via Digitalmars-d-learn
On Monday, 14 August 2017 at 01:52:16 UTC, Johnson Jones wrote: Error: uncaught CTFE exception std.format.FormatException("Cannot format floating point types at compile-time") called from here: to(0.75) pretty simply, trying to convert a floating point to a string in a ctf

Re: wth!! ctfe cannot format floating point at compile time?

2017-08-13 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 14 August 2017 at 01:52:16 UTC, Johnson Jones wrote: pretty simply, trying to convert a floating point to a string in a ctfe function and it thinks that it is too complex to do in a ctfe, really? It uses a C function to do the conversion, which is not available at compile time

wth!! ctfe cannot format floating point at compile time?

2017-08-13 Thread Johnson Jones via Digitalmars-d-learn
Error: uncaught CTFE exception std.format.FormatException("Cannot format floating point types at compile-time") called from here: to(0.75) pretty simply, trying to convert a floating point to a string in a ctfe function and it thinks that it is too complex to do in a ctfe, really?

Re: Format g bug ?

2017-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/9/17 4:10 PM, Temtaime wrote: Sorry, messed up numbers Expected: 3.11 3.11 3.1 3.1 Seems g outputs one digit less I was bugged by this too. It's not a bug. For the %f specifier, the number represents the number of digits *after* the decimal. For the %g specifier, the number

Re: Format g bug ?

2017-08-09 Thread Temtaime via Digitalmars-d-learn
Sorry, messed up numbers Expected: 3.11 3.11 3.1 3.1 Seems g outputs one digit less

Format g bug ?

2017-08-09 Thread Temtaime via Digitalmars-d-learn
import std.stdio; void main() { writefln(`%.2g`, 3.11); writefln(`%.2f`, 3.11); writefln(`%.1g`, 3.11); writefln(`%.1f`, 3.11); } 3.1 3.11 3 3.1 But expected 3.1 3.11 3.1 3.11

Re: Stack Trace format

2017-04-30 Thread Szabo Bogdan via Digitalmars-d-learn
the stack elements, but if I get a different format on different platforms it's not that easy to determine at what position in the string is the address or the function name. I would appreciate if anyone have an idea of how I can do this without a big headache... Thanks! Actually I found

Stack Trace format

2017-04-30 Thread Szabo Bogdan via Digitalmars-d-learn
Hi, I noticed that on different platforms the `object.Throwable.TraceInfo` has different formats. A program compiled on osx with ldc2 has all the TraceInfo empty... Why? I want to parse those strings or somehow iterate trough all the stack elements, but if I get a different format

Re: How to fix date format?

2017-04-26 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, April 26, 2017 06:55:01 Suliman via Digitalmars-d-learn wrote: > Thanks! That's work! > > But why I can't do it in single line like: > string dt = > DateTime.toISOExtString(DateTime.fromSimpleString(point[1].coerce!string)) > ; "Error: function std.datetime.DateTime.toISOExtString ()

Re: How to fix date format?

2017-04-26 Thread Suliman via Digitalmars-d-learn
is giving you a string in Boost's "simple time" format (e.g. "2016-Jan-04 12:19:17"), then DateTime.fromSimpleString(point[1].coerce!string) will give you a DateTime. Then if you called toISOExtString() on that, e.g. DateTime dt = DateTime.fromSimpleString(point[1].coerce

Re: How to fix date format?

2017-04-25 Thread Jonathan M Davis via Digitalmars-d-learn
is > not callable using argument types (DateTime) > Error: function database.Database.getSingleTrackInfo no return > exp; or assert(0); at end of function toISOExtString is a normal member function on DateTime, not a static member function. If point[1].coerce!string is giving you a string in

Re: How to fix date format?

2017-04-25 Thread Ali Çehreli via Digitalmars-d-learn
On 04/25/2017 10:41 AM, Suliman wrote: I am using mysql native. Date in DB have next format: 2016-11-01 06:19:37 But every tile when I am trying to get it I am getting such format: 2016-Oct-31 15:37:24 I use next code: writeln(point[1].coerce!string); Why coerce is forcing format changing

Re: How to fix date format?

2017-04-25 Thread Suliman via Digitalmars-d-learn
I tried to do: writeln(DateTime.toISOExtString(DateTime.fromSimpleString(point[1].coerce!string))); But got error: Error: function std.datetime.DateTime.toISOExtString () const is not callable using argument types (DateTime) Error: function database.Database.getSingleTrackInfo no return exp;

Re: How to fix date format?

2017-04-25 Thread Suliman via Digitalmars-d-learn
On Tuesday, 25 April 2017 at 20:10:02 UTC, Jonathan M Davis wrote: On Tuesday, April 25, 2017 17:41:25 Suliman via Digitalmars-d-learn wrote: I am using mysql native. Date in DB have next format: 2016-11-01 06:19:37 But every tile when I am trying to get it I am getting such format: 2016-Oct

Re: How to fix date format?

2017-04-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 25, 2017 17:41:25 Suliman via Digitalmars-d-learn wrote: > I am using mysql native. Date in DB have next format: 2016-11-01 > 06:19:37 > > But every tile when I am trying to get it I am getting such > format: > 2016-Oct-31 15:37:24 > > I use next code: &

How to fix date format?

2017-04-25 Thread Suliman via Digitalmars-d-learn
I am using mysql native. Date in DB have next format: 2016-11-01 06:19:37 But every tile when I am trying to get it I am getting such format: 2016-Oct-31 15:37:24 I use next code: writeln(point[1].coerce!string); Why coerce is forcing format changing? How I can extract result as without

Re: Difference between dstring and string format specifiers support. Bug?

2016-11-09 Thread Ali Çehreli via Digitalmars-d-learn
On 11/09/2016 01:20 AM, Ali Çehreli wrote: > arrayPtrDiff() is at the bottom of the same file but works correctly > only for char strings: > > https://github.com/dlang/phobos/blob/master/std/format.d#L6573 What I meant is, using arrayPtrDiff() is correct only for char strings. Otherwise,

Re: Difference between dstring and string format specifiers support. Bug?

2016-11-09 Thread Ali Çehreli via Digitalmars-d-learn
On 11/09/2016 12:21 AM, Vadim Lopatin wrote: Looks like bug. dchar[] and wchar[] format strings support less specifiers than char[] import std.format; string test1 = "%02d".format(1); // works assert(test1 == "01"); dstring test2 = "

Difference between dstring and string format specifiers support. Bug?

2016-11-09 Thread Vadim Lopatin via Digitalmars-d-learn
Looks like bug. dchar[] and wchar[] format strings support less specifiers than char[] import std.format; string test1 = "%02d".format(1); // works assert(test1 == "01"); dstring test2 = "%d"d.format(1); // works assert(t

Re: Difference between dstring and string format specifiers support. Bug?

2016-11-09 Thread Vadim Lopatin via Digitalmars-d-learn
On Wednesday, 9 November 2016 at 08:21:53 UTC, Vadim Lopatin wrote: Looks like bug. dchar[] and wchar[] format strings support less specifiers than char[] import std.format; string test1 = "%02d".format(1); // works assert(test1 == "01");

Re: How to use `format` to repeat a character

2016-07-11 Thread Bahman Movaqar via Digitalmars-d-learn
On 07/11/2016 03:02 PM, Mike Parker wrote: > You can do it in D with custom format specifiers. See: > > https://wiki.dlang.org/Defining_custom_print_format_specifiers Thanks for the pointer. I'll keep that in mind. -- Bahman

Re: How to use `format` to repeat a character

2016-07-11 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Jul 11, 2016 at 02:53:24PM +0430, Bahman Movaqar via Digitalmars-d-learn wrote: > On 07/11/2016 02:44 PM, ketmar wrote: [...] > > the fact that format can insert spaces. it is like: "ok, it can do > > spaces. i bet there should be some way to use any character instead

Re: How to use `format` to repeat a character

2016-07-11 Thread Meta via Digitalmars-d-learn
On Monday, 11 July 2016 at 09:02:12 UTC, Bahman Movaqar wrote: I'm sure I'm missing something very simple but how can I create a string like "" using `format`? I check the docs on `format` and tried many variations including `format("%.*c\n", 4, '-')` but got nowhere.

Re: How to use `format` to repeat a character

2016-07-11 Thread Mike Parker via Digitalmars-d-learn
On Monday, 11 July 2016 at 10:23:24 UTC, Bahman Movaqar wrote: On 07/11/2016 02:44 PM, ketmar wrote: On Monday, 11 July 2016 at 09:31:49 UTC, Ali Çehreli wrote: What makes you expect that format should have that feature? :) I somehow recalled I could do that in C

Re: How to use `format` to repeat a character

2016-07-11 Thread Bahman Movaqar via Digitalmars-d-learn
On 07/11/2016 02:44 PM, ketmar wrote: > On Monday, 11 July 2016 at 09:31:49 UTC, Ali Çehreli wrote: >> What makes you expect that format should have that feature? :) I somehow recalled I could do that in C and then there was the "minimum field width" in the docs, so I though

Re: How to use `format` to repeat a character

2016-07-11 Thread ketmar via Digitalmars-d-learn
On Monday, 11 July 2016 at 09:31:49 UTC, Ali Çehreli wrote: What makes you expect that format should have that feature? :) the fact that format can insert spaces. it is like: "ok, it can do spaces. i bet there should be some way to use any character instead of space. afte

Re: How to use `format` to repeat a character

2016-07-11 Thread ag0aep6g via Digitalmars-d-learn
On 07/11/2016 11:31 AM, Ali Çehreli wrote: // Another one that combines multiple range algorithms import std.range : iota; import std.algorithm : map; assert(7.iota.map!(i => i % 2 ? '=' : '-').equal("-=-=-=-")); An alternative without those scary modulo and ternary

Re: How to use `format` to repeat a character

2016-07-11 Thread Ali Çehreli via Digitalmars-d-learn
On 07/11/2016 02:02 AM, Bahman Movaqar wrote: > I'm sure I'm missing something very simple but how can I create a string > like "----" using `format`? You can't. > I check the docs on `format` and tried many variations including > `format("%.*c\n", 4, '-')`

How to use `format` to repeat a character

2016-07-11 Thread Bahman Movaqar via Digitalmars-d-learn
I'm sure I'm missing something very simple but how can I create a string like "" using `format`? I check the docs on `format` and tried many variations including `format("%.*c\n", 4, '-')` but got nowhere. I'd appreciate any hint/help on this. -- Bahman Movaqar http:/

Re: Best way to convert Apachelog Datetime 01/Jan/2016:02:25:10 -> 2016-01-01 02:25:10 MySQL-Datetime Format

2016-06-08 Thread Martin Tschierschke via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 10:42:19 UTC, Martin Tschierschke wrote: I know there are easy ways to handle this, anyone with a code snippet for me? I found this solution, letting the MySQL engine do the work: SELECT STR_TO_DATE('26/Apr/2011:13:21:58', '%d/%b/%Y:%H:%i:%S');

Best way to convert Apachelog Datetime 01/Jan/2016:02:25:10 -> 2016-01-01 02:25:10 MySQL-Datetime Format

2016-06-08 Thread Martin Tschierschke via Digitalmars-d-learn
I know there are easy ways to handle this, anyone with a code snippet for me? I would use two regex first to make 01,02,03... from Jan,Feb,.. and second to split the result. best regards mt.

Re: Unterminated format specifier exception keeps occuring and I don't know why.

2016-01-31 Thread Enjoys Math via Digitalmars-d-learn
On Sunday, 31 January 2016 at 19:51:34 UTC, Enjoys Math wrote: On Sunday, 31 January 2016 at 19:40:15 UTC, Enjoys Math wrote: This weird exception keeps occuring and visual D is not bringing me to the place in my code that might be calling it. [...] The exception is not listed in the

Unterminated format specifier exception keeps occuring and I don't know why.

2016-01-31 Thread Enjoys Math via Digitalmars-d-learn
This weird exception keeps occuring and visual D is not bringing me to the place in my code that might be calling it. Message: First-chance exception: std.format.FormatException Unterminated format specifier: "%" at C:\D\dmd2\windows\bin\..\..\src\phobos\std\format.d(830) I've

Re: Unterminated format specifier exception keeps occuring and I don't know why.

2016-01-31 Thread Enjoys Math via Digitalmars-d-learn
On Sunday, 31 January 2016 at 19:40:15 UTC, Enjoys Math wrote: This weird exception keeps occuring and visual D is not bringing me to the place in my code that might be calling it. [...] The exception is not listed in the Exception Settings checkable list. I will try commenting out the D

Re: core.time Duration how to get units in double/float format?

2016-01-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, January 19, 2016 14:07:50 Borislav Kosharov via Digitalmars-d-learn wrote: > On Monday, 18 January 2016 at 12:46:31 UTC, Jonathan M Davis > wrote: > > In general, using floating point values with time is an > > incredibly bad idea. It can certainly make sense when printing > > stuff

Re: core.time Duration how to get units in double/float format?

2016-01-19 Thread Borislav Kosharov via Digitalmars-d-learn
On Tuesday, 19 January 2016 at 15:25:58 UTC, wobbles wrote: On Tuesday, 19 January 2016 at 14:07:50 UTC, Borislav Kosharov wrote: On Monday, 18 January 2016 at 12:46:31 UTC, Jonathan M Davis wrote: [...] I want to use float time in a game where I call the update method passing the delta

Re: core.time Duration how to get units in double/float format?

2016-01-19 Thread Borislav Kosharov via Digitalmars-d-learn
On Monday, 18 January 2016 at 12:46:31 UTC, Jonathan M Davis wrote: In general, using floating point values with time is an incredibly bad idea. It can certainly make sense when printing stuff out, but using it in calculations is just asking for trouble given all of the unnecessary imprecision

Re: core.time Duration how to get units in double/float format?

2016-01-19 Thread wobbles via Digitalmars-d-learn
On Tuesday, 19 January 2016 at 14:07:50 UTC, Borislav Kosharov wrote: On Monday, 18 January 2016 at 12:46:31 UTC, Jonathan M Davis wrote: [...] I want to use float time in a game where I call the update method passing the delta time as float seconds. It's more easy to multiply the dt with a

Re: core.time Duration how to get units in double/float format?

2016-01-18 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, January 17, 2016 14:43:26 Borislav Kosharov via Digitalmars-d-learn wrote: > Seeing that TickDuration is being deprecated and that I should > use Duration instead, I faced a problem. I need to get total > seconds like a float. Using .total!"seconds" returns a long and > if the duration

Re: core.time Duration how to get units in double/float format?

2016-01-17 Thread Borislav Kosharov via Digitalmars-d-learn
On Sunday, 17 January 2016 at 18:57:13 UTC, biozic wrote: On Sunday, 17 January 2016 at 14:43:26 UTC, Borislav Kosharov wrote: Seeing that TickDuration is being deprecated and that I should use Duration instead, I faced a problem. I need to get total seconds like a float. Using

Re: core.time Duration how to get units in double/float format?

2016-01-17 Thread biozic via Digitalmars-d-learn
On Sunday, 17 January 2016 at 14:43:26 UTC, Borislav Kosharov wrote: Seeing that TickDuration is being deprecated and that I should use Duration instead, I faced a problem. I need to get total seconds like a float. Using .total!"seconds" returns a long and if the duration is less than 1 second

core.time Duration how to get units in double/float format?

2016-01-17 Thread Borislav Kosharov via Digitalmars-d-learn
Seeing that TickDuration is being deprecated and that I should use Duration instead, I faced a problem. I need to get total seconds like a float. Using .total!"seconds" returns a long and if the duration is less than 1 second I get 0. My question is whats the right way to do it. Because I saw

DUB config format: SDLang or JSON?

2015-12-18 Thread Jakob Jenkov via Digitalmars-d-learn
I am just looking at DUB and I can read that there are two config formats: SDLang and JSON. Which one is the "new" format? Which one is the "future" of DUB?

Re: DUB config format: SDLang or JSON?

2015-12-18 Thread Brad Anderson via Digitalmars-d-learn
On Friday, 18 December 2015 at 22:30:00 UTC, Jakob Jenkov wrote: I am just looking at DUB and I can read that there are two config formats: SDLang and JSON. Which one is the "new" format? Which one is the "future" of DUB? SDLang is the new one. JSON will remain supported

Re: regex format string problem

2015-11-23 Thread Rikki Cattermole via Digitalmars-d-learn
On 23/11/15 9:22 PM, yawniek wrote: Hi Rikki, On Monday, 23 November 2015 at 03:57:06 UTC, Rikki Cattermole wrote: I take it that browscap[0] does it not do what you want? I have an generator at [1]. Feel free to steal. This looks interesting, thanks for the hint. However it might be a bit

Re: regex format string problem

2015-11-23 Thread yawniek via Digitalmars-d-learn
Hi Rikki, On Monday, 23 November 2015 at 03:57:06 UTC, Rikki Cattermole wrote: I take it that browscap[0] does it not do what you want? I have an generator at [1]. Feel free to steal. This looks interesting, thanks for the hint. However it might be a bit limited, i have 15M+ different User

regex format string problem

2015-11-22 Thread yawniek via Digitalmars-d-learn
hi! how can i format a string with captures from a regular expression? basically make this pass: https://gist.github.com/f17647fb2f8ff2261d42 context: i'm trying to write a implementation for https://github.com/ua-parser where the regular expression as well as the format strings are given.

Re: regex format string problem

2015-11-22 Thread Rikki Cattermole via Digitalmars-d-learn
On 23/11/15 12:41 PM, yawniek wrote: hi! how can i format a string with captures from a regular expression? basically make this pass: https://gist.github.com/f17647fb2f8ff2261d42 context: i'm trying to write a implementation for https://github.com/ua-parser where the regular expression

writef format specifier error message

2015-11-16 Thread ric maicle via Digitalmars-d-learn
I accidentally typed an extra asterisk in the format specifier. I know that it is wrong but the error isn't clear about what and where the error is. import std.stdio; void main() { writef("%*10s", 100); } and I got the following error message(s): $ dmd -run writef.d std.format.Forma

Re: writef format specifier error message

2015-11-16 Thread Ali Çehreli via Digitalmars-d-learn
On 11/16/2015 10:56 AM, ric maicle wrote: I accidentally typed an extra asterisk in the format specifier. I know that it is wrong but the error isn't clear about what and where the error is. import std.stdio; void main() { writef("%*10s", 100); } and I got the following error

Re: writef format specifier error message

2015-11-16 Thread ric maicle via Digitalmars-d-learn
On Tuesday, 17 November, 2015 03:49 AM, Ali Çehreli wrote: On 11/16/2015 10:56 AM, ric maicle wrote: I accidentally typed an extra asterisk in the format specifier. I know that it is wrong but the error isn't clear about what and where the error is. import std.stdio; void main() { writef

Re: Bloat with std.(string.)format?

2015-09-18 Thread Kagamin via Digitalmars-d-learn
On Thursday, 17 September 2015 at 15:45:10 UTC, Chris wrote: I suppose it's an area most people (including myself) shy away from. I know next to nothing about compiler implementation. Sometimes it's just diagnosis of test failures.

Bloat with std.(string.)format?

2015-09-17 Thread Chris via Digitalmars-d-learn
If I have code like this: auto builder = appender!string; builder ~= "Hello, World!"; builder ~= "I'm here!"; builder ~= "Now I'm there!"; the object file grows by 10-11 lines with each call to `builder ~=`. If I use this: builder ~= format("%s",

Re: Bloat with std.(string.)format?

2015-09-17 Thread John Colvin via Digitalmars-d-learn
~=`. If I use this: builder ~= format("%s", "Hello, World!"); builder ~= format("%s", "I'm here!"); builder ~= format("%s", "Now I'm there!"); The object file is more than twice as big and it grows by 20 lines with each call to `

Re: Bloat with std.(string.)format?

2015-09-17 Thread Chris via Digitalmars-d-learn
On Thursday, 17 September 2015 at 10:33:44 UTC, John Colvin wrote: Some initial bloat is expected, format is pretty big (although twice as big is a lot, unless your original code was quite small?). It was in a test program. Only a few lines. But it would still add a lot of bloat

Re: Bloat with std.(string.)format?

2015-09-17 Thread John Colvin via Digitalmars-d-learn
On Thursday, 17 September 2015 at 10:53:17 UTC, Chris wrote: On Thursday, 17 September 2015 at 10:33:44 UTC, John Colvin wrote: Some initial bloat is expected, format is pretty big (although twice as big is a lot, unless your original code was quite small?). It was in a test program. Only

Re: Bloat with std.(string.)format?

2015-09-17 Thread Chris via Digitalmars-d-learn
On Thursday, 17 September 2015 at 15:17:21 UTC, John Colvin wrote: On Thursday, 17 September 2015 at 13:42:15 UTC, Chris wrote: On Thursday, 17 September 2015 at 12:49:03 UTC, John Colvin wrote: [...] Thanks. That's up to date enough now. Is it stable, though? Reasonably so in my testing,

Re: Bloat with std.(string.)format?

2015-09-17 Thread John Colvin via Digitalmars-d-learn
On Thursday, 17 September 2015 at 13:42:15 UTC, Chris wrote: On Thursday, 17 September 2015 at 12:49:03 UTC, John Colvin wrote: [...] Thanks. That's up to date enough now. Is it stable, though? Reasonably so in my testing, but expect more bugs than in a full release. For version 2.067.1

Re: Bloat with std.(string.)format?

2015-09-17 Thread Chris via Digitalmars-d-learn
On Thursday, 17 September 2015 at 12:49:03 UTC, John Colvin wrote: On Thursday, 17 September 2015 at 10:53:17 UTC, Chris wrote: On Thursday, 17 September 2015 at 10:33:44 UTC, John Colvin wrote: Some initial bloat is expected, format is pretty big (although twice as big is a lot, unless your

Re: Speeding up text file parser (BLAST tabular format)

2015-09-15 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Sep 15, 2015 at 08:55:43AM +, Fredrik Boulund via Digitalmars-d-learn wrote: > On Monday, 14 September 2015 at 18:31:38 UTC, H. S. Teoh wrote: > >I tried implementing a crude version of this (see code below), and > >found that manually calling GC.collect() even as frequently as once >

Re: Speeding up text file parser (BLAST tabular format)

2015-09-15 Thread Andrew Brown via Digitalmars-d-learn
I had some luck building a local copy of llvm in my home directory, using a linux version about as old as yours (llvm 3.5 i used) specifying: --configure --prefix=/home/andrew/llvm so make install would install it somewhere I had permissions. Then I changed the cmake command to: cmake -L

Re: Speeding up text file parser (BLAST tabular format)

2015-09-15 Thread Rikki Cattermole via Digitalmars-d-learn
On 15/09/15 9:00 PM, Kagamin wrote: On Tuesday, 15 September 2015 at 08:51:02 UTC, Fredrik Boulund wrote: Using char[] all around might be a good idea, but it doesn't seem like the string conversions are really that taxing. What are the arguments for working on char[] arrays rather than

Re: Speeding up text file parser (BLAST tabular format)

2015-09-15 Thread John Colvin via Digitalmars-d-learn
On Tuesday, 15 September 2015 at 09:09:00 UTC, Kagamin wrote: On Tuesday, 15 September 2015 at 08:53:37 UTC, Fredrik Boulund wrote: my favourite for streaming a file: enum chunkSize = 4096; File(fileName).byChunk(chunkSize).map!"cast(char[])a".joiner() Is this an efficient way of reading this

Re: Speeding up text file parser (BLAST tabular format)

2015-09-15 Thread Fredrik Boulund via Digitalmars-d-learn
On Monday, 14 September 2015 at 18:31:38 UTC, H. S. Teoh wrote: I tried implementing a crude version of this (see code below), and found that manually calling GC.collect() even as frequently as once every 5000 loop iterations (for a 500,000 line test input file) still gives about 15%

Re: Speeding up text file parser (BLAST tabular format)

2015-09-15 Thread Fredrik Boulund via Digitalmars-d-learn
On Monday, 14 September 2015 at 16:13:14 UTC, Edwin van Leeuwen wrote: See this link for clarification on what the columns/numbers in the profile file mean http://forum.dlang.org/post/f9gjmo$2gce$1...@digitalmars.com It is still difficult to parse though. I myself often use sysprof (only

<    1   2   3   4   >