Re: Multiple %s format specifiers with a single argument

2012-04-10 Thread Jonathan M Davis
On Tuesday, April 10, 2012 13:06:08 Stewart Gordon wrote: > On 09/04/2012 18:35, Andrej Mitrovic wrote: > > On 4/9/12, Jonathan M Davis wrote: > >> Posix positional arguments seem to work for writefln but not format for > >> whatever reason. Report it as a

Re: Multiple %s format specifiers with a single argument

2012-04-10 Thread Andrej Mitrovic
On 4/10/12, Andrej Mitrovic wrote: > E.g. if I search for "format > positional" I get this lone result: > > http://d.puremagic.com/issues/buglist.cgi?quicksearch=format+positional I mean this result: http://d.puremagic.com/issues/show_bug.cgi?id=4927

Re: Multiple %s format specifiers with a single argument

2012-04-10 Thread Andrej Mitrovic
te: > You shouldn't submit bug reports without searching first anyway. I did, but the default search box doesn't seem to search duplicate reports (I didn't know this until now). E.g. if I search for "format positional" I get this lone result: http://d.puremagic.com/iss

Re: Multiple %s format specifiers with a single argument

2012-04-10 Thread Stewart Gordon
On 09/04/2012 18:35, Andrej Mitrovic wrote: On 4/9/12, Jonathan M Davis wrote: Posix positional arguments seem to work for writefln but not format for whatever reason. Report it as a bug. Thanks, http://d.puremagic.com/issues/show_bug.cgi?id=7877 Andrej, are emails from Bugzilla not

Re: Multiple %s format specifiers with a single argument

2012-04-10 Thread Mike Parker
On 4/10/2012 3:43 AM, Ali Çehreli wrote: On 04/09/2012 10:35 AM, Andrej Mitrovic wrote: On 4/9/12, Jonathan M Davis wrote: Posix positional arguments seem to work for writefln but not format for whatever reason. Report it as a bug. Thanks, http://d.puremagic.com/issues/show_bug.cgi?id=7877

Re: Multiple %s format specifiers with a single argument

2012-04-09 Thread q66
On Monday, 9 April 2012 at 17:24:35 UTC, Andrej Mitrovic wrote: On 4/9/12, q66 wrote: Positional specifier works just fine for me. Which version are you using? I'm on 2.058. git

Re: Multiple %s format specifiers with a single argument

2012-04-09 Thread Ali Çehreli
On 04/09/2012 10:35 AM, Andrej Mitrovic wrote: On 4/9/12, Jonathan M Davis wrote: Posix positional arguments seem to work for writefln but not format for whatever reason. Report it as a bug. Thanks, http://d.puremagic.com/issues/show_bug.cgi?id=7877 Thanks. I hadn't seen this branch o

Re: Multiple %s format specifiers with a single argument

2012-04-09 Thread Ali Çehreli
On 04/09/2012 10:24 AM, Andrej Mitrovic wrote: On 4/9/12, q66 wrote: Positional specifier works just fine for me. Which version are you using? I'm on 2.058. Positional parameters[*] are supported in 2.058. This example prints the same argument in decimal, hexadecimal, octal, and binary:

Re: Multiple %s format specifiers with a single argument

2012-04-09 Thread Andrej Mitrovic
On 4/9/12, Jonathan M Davis wrote: > Posix positional arguments seem to work for writefln but not format for > whatever reason. Report it as a bug. Thanks, http://d.puremagic.com/issues/show_bug.cgi?id=7877

Re: Multiple %s format specifiers with a single argument

2012-04-09 Thread Jonathan M Davis
On Monday, April 09, 2012 19:08:54 Andrej Mitrovic wrote: > import std.string; > > void main() > { > string foo = "foo"; > string bar = format("%s %s %s", foo); > } > > format expects 3 arguments, but what I really want is foo to be used >

Re: Multiple %s format specifiers with a single argument

2012-04-09 Thread Andrej Mitrovic
On 4/9/12, q66 wrote: > Positional specifier works just fine for me. Which version are you using? I'm on 2.058.

Re: Multiple %s format specifiers with a single argument

2012-04-09 Thread q66
On Monday, 9 April 2012 at 17:09:03 UTC, Andrej Mitrovic wrote: import std.string; void main() { string foo = "foo"; string bar = format("%s %s %s", foo); } format expects 3 arguments, but what I really want is foo to be used for all 3 specifiers and not repeat &#

Multiple %s format specifiers with a single argument

2012-04-09 Thread Andrej Mitrovic
import std.string; void main() { string foo = "foo"; string bar = format("%s %s %s", foo); } format expects 3 arguments, but what I really want is foo to be used for all 3 specifiers and not repeat 'foo' 3 times manually. Are there any format specifiers t

Re: about std.csv and derived format

2012-03-01 Thread Jesse Phillips
On Thursday, 1 March 2012 at 10:09:55 UTC, bioinfornatics wrote: and how convert bedInstances input array to BedData11[] ? std.array.array()

Re: about std.csv and derived format

2012-03-01 Thread bioinfornatics
Le jeudi 01 mars 2012 à 04:36 +0100, Jesse Phillips a écrit : > On Thursday, 1 March 2012 at 02:07:44 UTC, bioinfornatics wrote: > > > It is ok i have found a way maybe is not an efficient way but > > it works: > > https://gist.github.com/1946669 > > > > a minor bug exist for parse track line wil

Re: about std.csv and derived format

2012-02-29 Thread Jesse Phillips
On Thursday, 1 March 2012 at 02:07:44 UTC, bioinfornatics wrote: It is ok i have found a way maybe is not an efficient way but it works: https://gist.github.com/1946669 a minor bug exist for parse track line will be fixed tomorrow. time to bed Big thanks to all You can edit a gist instea

Re: about std.csv and derived format

2012-02-29 Thread bioinfornatics
fornatics a > > > écrit : > > >> Dear, > > >> > > >> I would like to parse this file: > > >> http://genome.ucsc.edu/goldenPath/help/ItemRGBDemo.txt > > > > > My problem is: > > > - need to parse data in csv format >

Re: about std.csv and derived format

2012-02-29 Thread bioinfornatics
t; I would like to parse this file: > >> http://genome.ucsc.edu/goldenPath/help/ItemRGBDemo.txt > > > My problem is: > > - need to parse data in csv format > > - how manage with optional field > > It looks like the data is tab delimited so separator is a tab. > There

Re: about std.csv and derived format

2012-02-29 Thread Jesse Phillips
On Wednesday, 29 February 2012 at 11:51:29 UTC, bioinfornatics wrote: Le mercredi 29 février 2012 à 12:42 +0100, bioinfornatics a écrit : Dear, I would like to parse this file: http://genome.ucsc.edu/goldenPath/help/ItemRGBDemo.txt My problem is: - need to parse data in csv format - how

Re: about std.csv and derived format

2012-02-29 Thread bioinfornatics
data so they should be parsed by hand. browser position chr7:127471196-127495720 browser hide all track name="ItemRGBDemo" description="Item RGB demonstration" visibility=2 itemRgb="On" My problem is: - need to parse data in csv format - how manage with optional field

about std.csv and derived format

2012-02-29 Thread bioinfornatics
Dear, I would like to parse this file: http://genome.ucsc.edu/goldenPath/help/ItemRGBDemo.txt struct Bed{ stringchrom;// 0 size_tchromStart; // 1 size_tchromEnd; // 2 stringname; // 3 size_tscore;// 4

Re: format a string like sprintf?

2011-08-16 Thread Vijay Nayar
On Tue, 16 Aug 2011 13:23:26 +, teo wrote: > What is the correct way in D to format a string like sprintf? I need to > pad a number with zeroes. I tried to use std.format.format and > std.string.format, but had some strange results. You can go ahead and use the normal std.

Re: format a string like sprintf?

2011-08-16 Thread teo
On Tue, 16 Aug 2011 09:51:41 -0400, bearophile wrote: > teo: > >> What is the correct way in D to format a string like sprintf? I need to >> pad a number with zeroes. I tried to use std.format.format and >> std.string.format, but had some strange results. > >

Re: format a string like sprintf?

2011-08-16 Thread Andrej Mitrovic
Is this what you're after? import std.string; void main() { auto str = format("%.4s", 4); assert(str == "0004"); }

Re: format a string like sprintf?

2011-08-16 Thread Steven Schveighoffer
On Tue, 16 Aug 2011 09:32:47 -0400, Steven Schveighoffer wrote: On Tue, 16 Aug 2011 09:23:26 -0400, teo wrote: What is the correct way in D to format a string like sprintf? I need to pad a number with zeroes. I tried to use std.format.format and std.string.format, but had some strange

Re: format a string like sprintf?

2011-08-16 Thread bearophile
teo: > What is the correct way in D to format a string like sprintf? I need to > pad a number with zeroes. I tried to use std.format.format and > std.string.format, but had some strange results. Why don't you show one or more complete runnable examples that show your strange re

Re: format a string like sprintf?

2011-08-16 Thread Steven Schveighoffer
On Tue, 16 Aug 2011 09:23:26 -0400, teo wrote: What is the correct way in D to format a string like sprintf? I need to pad a number with zeroes. I tried to use std.format.format and std.string.format, but had some strange results. I think maybe std.string.format? I realize looking at the

format a string like sprintf?

2011-08-16 Thread teo
What is the correct way in D to format a string like sprintf? I need to pad a number with zeroes. I tried to use std.format.format and std.string.format, but had some strange results.

Re: format()

2011-06-12 Thread Lloyd Dupont
> mm... ok. > but why the line below doesn't compile? > > mixin(format("class %s {}", "A")); Because format presumably can't be interpreted at compile time (yet) – not all functions are necessarily CTFEable. Yeah. format can only be used at runtime. If you w

Re: format()

2011-06-12 Thread jdrewsen
Den 12-06-2011 18:37, Lloyd Dupont skrev: mm... ok. but why the line below doesn't compile? mixin(format("class %s {}", "A")); Because the mixin is evaluated at compile time. This means that format(...) is evaluated at compile time which afaik is not supported. I

Re: format()

2011-06-12 Thread Jonathan M Davis
On 2011-06-12 10:30, David Nadlinger wrote: > On 6/12/11 6:37 PM, Lloyd Dupont wrote: > > mm... ok. > > but why the line below doesn't compile? > > > > mixin(format("class %s {}", "A")); > > Because format presumably can't

Re: format()

2011-06-12 Thread David Nadlinger
On 6/12/11 6:37 PM, Lloyd Dupont wrote: mm... ok. but why the line below doesn't compile? mixin(format("class %s {}", "A")); Because format presumably can't be interpreted at compile time (yet) – not all functions are necessarily CTFEable. David

Re: format()

2011-06-12 Thread Lloyd Dupont
mm... ok. but why the line below doesn't compile? mixin(format("class %s {}", "A")); "bearophile" wrote in message news:it2pf5$1qh6$1...@digitalmars.com... Apparently std.string.format() is not implemented / does not compile! :( This works for me, DMD 2.053:

Re: format()

2011-06-12 Thread bearophile
Lloyd Dupon: > Apparently std.string.format() is not implemented / does not compile! :( This works for me, DMD 2.053: import std.stdio, std.string; void main() { int x = 10; auto s = format("%d", 10); writeln(">", s, "<"); } Bye, bearophile

format()

2011-06-12 Thread Lloyd Dupont
Apparently std.string.format() is not implemented / does not compile! :( Is there any sort of replacement? Something which works like writefln() but output a string!

Re: Should writef try to statically check for format specifiers?

2011-04-26 Thread Peter Alexander
On 11/04/11 9:35 PM, Andrej Mitrovic wrote: I realize runtime checks would be out of the question... debug doRuntimeCheck(); :-)

Re: Should writef try to statically check for format specifiers?

2011-04-12 Thread Andrej Mitrovic
On 4/12/11, bearophile wrote: > Template functions may not require a bang+types if argument > types can be inferred from the given arguments. So isn't the string literal a candidate in this case?

Re: Should writef try to statically check for format specifiers?

2011-04-12 Thread bearophile
Andrej Mitrovic: > I thought templated functions can be called without a bang if an > argument can be deduced to be available at compile time. I know I've > read about this somewhere, either TDPL or the docs. So I thought that > writef checks the string literal at compile time, not runtime. I thi

Re: Should writef try to statically check for format specifiers?

2011-04-12 Thread Andrej Mitrovic
I thought templated functions can be called without a bang if an argument can be deduced to be available at compile time. I know I've read about this somewhere, either TDPL or the docs. So I thought that writef checks the string literal at compile time, not runtime. Template shenanigans..

Re: Should writef try to statically check for format specifiers?

2011-04-12 Thread Steven Schveighoffer
missing a format specifier. But it still accepts this code. Is it possible for writef to statically check whether there's a format specifier, assuming there's multiple arguments and the first argument is a string literal? I realize runtime checks would be out of the question, but I

Re: Should writef try to statically check for format specifiers?

2011-04-11 Thread Andrej Mitrovic
On 4/12/11, Jesse Phillips wrote: > On Tue, 12 Apr 2011 01:55:24 +0200, Andrej Mitrovic wrote: > >> On 4/12/11, Jesse Phillips wrote: >>> Andrej Mitrovic Wrote: >>> %s doesn't stand for string in D. >>> >>> Yes it does. >> >> I was quoting bearophile's "it should error" post, you know that.

Re: Should writef try to statically check for format specifiers?

2011-04-11 Thread Jesse Phillips
On Tue, 12 Apr 2011 01:55:24 +0200, Andrej Mitrovic wrote: > On 4/12/11, Jesse Phillips wrote: >> Andrej Mitrovic Wrote: >> >>> %s doesn't stand for string in D. >> >> Yes it does. > > I was quoting bearophile's "it should error" post, you know that. I do now. Though it still stands for string

Re: Should writef try to statically check for format specifiers?

2011-04-11 Thread bearophile
Jesse Phillips: > Two complaints: > > fprintf? A leading f is for file. > %s means format as a string not the type is a string. Sorry, you are right, I am silly. Bye, bearophile

Re: Should writef try to statically check for format specifiers?

2011-04-11 Thread Andrej Mitrovic
On 4/12/11, Jesse Phillips wrote: > Andrej Mitrovic Wrote: > >> %s doesn't stand for string in D. > > Yes it does. I was quoting bearophile's "it should error" post, you know that.

Re: Should writef try to statically check for format specifiers?

2011-04-11 Thread Jesse Phillips
or: bar isn't a string! Two complaints: fprintf? A leading f is for file. %s means format as a string not the type is a string. > Bye, > bearophile

Re: Should writef try to statically check for format specifiers?

2011-04-11 Thread Jesse Phillips
Andrej Mitrovic Wrote: > %s doesn't stand for string in D. Yes it does. > My issue is that the arguments don't get printed out due to missing > specifiers. That is clearly a bug. But maybe it's not a huge bug since > it's just printing that is involved. I think it should do what it use to do w

Re: Should writef try to statically check for format specifiers?

2011-04-11 Thread Andrej Mitrovic
%s doesn't stand for string in D. My issue is that the arguments don't get printed out due to missing specifiers. That is clearly a bug. But maybe it's not a huge bug since it's just printing that is involved.

Re: Should writef try to statically check for format specifiers?

2011-04-11 Thread bearophile
Andrej Mitrovic: > I realize runtime checks would be out of the question, but I'm looking for > compile-time checks when it's possible to do so. GCC is often able to catch such bugs, but Walter has recently closed my enhancement request about this :-( http://d.puremagic.com/issues/show_bug.cgi?

Should writef try to statically check for format specifiers?

2011-04-11 Thread Andrej Mitrovic
There is a bug here: import std.stdio; void main() { int index; writef("The index is", index); } Actually I found this bug in some example code: http://d.puremagic.com/issues/show_bug.cgi?id=5836 writef is missing a format specifier. But it still accepts this code. Is i

Dependencies file format

2011-03-13 Thread Bekenn
After some searching, I found the documentation here: http://d.puremagic.com/issues/show_bug.cgi?id=3122 Shouldn't this be on the web site somewhere?

Re: wstring format

2011-02-20 Thread Jonathan M Davis
On Sunday 20 February 2011 21:26:05 Bekenn wrote: > Is there a wstring version of string.format? I can't seem to find it > anywhere... There probably isn't one. A lot of functions are string-only and do not work with char[], wchar[], dchar[], wstring, or dstring. That may or may not change in t

wstring format

2011-02-20 Thread Bekenn
Is there a wstring version of string.format? I can't seem to find it anywhere...

[D1] %a format to float

2010-11-04 Thread %u
%a looks neat as a lossless float formatter, but how do I get the float back from the string?

Re: Convert strings with different format to float

2010-09-08 Thread Tom Kazimiers
On 09/08/2010 06:58 PM, Stanislav Blinov wrote: > 08.09.2010 20:46, Tom Kazimiers wrote: >> Great! I am looking forward to that release :-). Any idea when it will >> be available? >> >> For the mean time I will, as proposed, make a separate function that >> checks if there is a dot in it or not. T

Re: Convert strings with different format to float

2010-09-08 Thread Stanislav Blinov
08.09.2010 20:46, Tom Kazimiers wrote: Great! I am looking forward to that release :-). Any idea when it will be available? For the mean time I will, as proposed, make a separate function that checks if there is a dot in it or not. Then I take to!float and to!int, respectively. Cheers, Tom Tha

Re: Convert strings with different format to float

2010-09-08 Thread Tom Kazimiers
you could try >> parse(). It might be more forgiving. >> >> - Jonathan M Davis > > No it wouldn't :) > It's indeed a bug, and it happens if string contains e.g. single 0 > (other digits are parsed normally). It seems that parse for floating > points tries to determine

Re: Convert strings with different format to float

2010-09-08 Thread Tom Kazimiers
Hi, On 09/08/2010 05:38 PM, Don wrote: > Pelle wrote: >> On 09/08/2010 09:23 AM, Tom Kazimiers wrote: >>> [ ..] >>> Maybe a to!float that can cope with >>> numbers without decimal point. >> >> You seem to have found a bug in to!float :-) >> >> to!float("123") works as expected, but to!float("0") b

Re: Convert strings with different format to float

2010-09-08 Thread Don
Pelle wrote: On 09/08/2010 09:23 AM, Tom Kazimiers wrote: Hi, I try to read data in from a file. This data consist mainly of numbers and I have a hard time converting it to number type variables. Two data lines could look like this v 0 0 0 v 1.5 1.2 0 Now I want to parse those lines and call

Re: Convert strings with different format to float

2010-09-08 Thread Pelle
On 09/08/2010 09:23 AM, Tom Kazimiers wrote: Hi, I try to read data in from a file. This data consist mainly of numbers and I have a hard time converting it to number type variables. Two data lines could look like this v 0 0 0 v 1.5 1.2 0 Now I want to parse those lines and call a method, the

Re: Convert strings with different format to float

2010-09-08 Thread Stanislav Blinov
a float. That way, you wouldn't have to keep worrying about it. Also, you could try parse(). It might be more forgiving. - Jonathan M Davis No it wouldn't :) It's indeed a bug, and it happens if string contains e.g. single 0 (other digits are parsed normally). It seems that parse fo

Re: Convert strings with different format to float

2010-09-08 Thread Jonathan M Davis
On Wednesday 08 September 2010 00:23:31 Tom Kazimiers wrote: > Hi, > > I try to read data in from a file. This data consist mainly of numbers > and I have a hard time converting it to number type variables. Two data > lines could look like this > > v 0 0 0 > v 1.5 1.2 0 > > Now I want to parse t

Convert strings with different format to float

2010-09-08 Thread Tom Kazimiers
Hi, I try to read data in from a file. This data consist mainly of numbers and I have a hard time converting it to number type variables. Two data lines could look like this v 0 0 0 v 1.5 1.2 0 Now I want to parse those lines and call a method, the line in passed (as char[]) to it: int index =

Re: D2: Indexed format specifiers?

2010-07-29 Thread Nick Sabalausky
"Jonathan M Davis" wrote in message news:mailman.49.1280424679.13841.digitalmars-d-le...@puremagic.com... > On Thursday, July 29, 2010 00:54:27 Nick Sabalausky wrote: >> I could have sworn I saw Andrei say somewhere a while ago that Phobos2 >> supported posix-style

Re: D2: Indexed format specifiers?

2010-07-29 Thread Jonathan M Davis
On Thursday, July 29, 2010 00:54:27 Nick Sabalausky wrote: > I could have sworn I saw Andrei say somewhere a while ago that Phobos2 > supported posix-style indexed format specifiers. From what I could figure > out from some searching that on the web, those are like "%1$s". Bu

D2: Indexed format specifiers?

2010-07-29 Thread Nick Sabalausky
I could have sworn I saw Andrei say somewhere a while ago that Phobos2 supported posix-style indexed format specifiers. From what I could figure out from some searching that on the web, those are like "%1$s". But this gives me a FormatException: "%1$s".format("A"

Re: D styled data format, Json failed

2009-05-06 Thread Saaa
Thanks! With this I can go on for a bit :) "Christopher Wright" wrote in message news:gtrpo7$2h7...@digitalmars.com... > Saaa wrote: >> My first stab at the get function. >> As you might see, I need help :D >> Thanks! >> >> How do I make the function take a variadic argument and get its type? >

Re: D styled data format, Json failed

2009-05-06 Thread Christopher Wright
Saaa wrote: My first stab at the get function. As you might see, I need help :D Thanks! How do I make the function take a variadic argument and get its type? void get(in char[][] file, in char[] identifier, ...) { TypeInfo type = _arguments[0]; void* var = _argptr; // e

Re: D styled data format, Json failed

2009-05-05 Thread Saaa
My first stab at the get function. As you might see, I need help :D Thanks! How do I make the function take a variadic argument and get its type? //I guess the void pointer isn't the correct way, but I don't know any other way void get(in char[][] file, in char[] indentifier, void* var) { TypeI

Re: D styled data format, Json failed

2009-05-05 Thread Saaa
ional array in JSON we may never know :D > You still have to parse and check everything since > it remains a text based format. I will be focussed on (safe) speed and not flexibility because as you mention otherwise it might be useless for the large arrays I wish to get/write > > I

Re: D styled data format, Json failed

2009-05-04 Thread Lutger
Saaa wrote: > > I looked at the JSON format and it seems very inefficient at loading arrays > as it isn't limited to one type per array. > This is nice when you want to save a small array with different typed > elements but for my purposes this is kind of a performance p

Re: D styled data format, Json failed

2009-05-04 Thread nobody
"Saaa" wrote in message news:gtlrs3$1b9...@digitalmars.com... > > I looked at the JSON format and it seems very inefficient at loading > arrays as it isn't limited to one type per array. > This is nice when you want to save a small array with different typed > ele

D styled data format, Json failed

2009-05-03 Thread Saaa
I looked at the JSON format and it seems very inefficient at loading arrays as it isn't limited to one type per array. This is nice when you want to save a small array with different typed elements but for my purposes this is kind of a performance problem. This is why I will try an

<    1   2   3   4