I'm stuck here, I am trying to print date which is in this format "2012/04/23" using io:format/2, but I want it to be printed like this: 2012/04/23 without invited commas, how do I go about resolving this?
Use ~s instead of ~p in the format argument of io:format/2:
1> io:format("~s~n", ["2012/04/23"]).
2012/04/23
On Wed, 14 Nov 2012, Lucky wrote:
> Hi Erlang Developers'
> I'm stuck here, I am trying to print date which is in this format "2012/04/23" using io:format/2, but I want it to be printed like this: 2012/04/23 without invited commas, how do I go about resolving this?
When you know what function you need to use but want to change some minor
behaviour check the documentation for it http://erldocs.com/ has a good
search function for finding the documentation for most Erlang functions.
> > I'm stuck here, I am trying to print date which is in this format
> "2012/04/23" using io:format/2, but I want it to be printed like this:
> 2012/04/23 without invited commas, how do I go about resolving this?
On Wed, Nov 14, 2012 at 5:06 PM, Lucky <mrkh...@gmail.com> wrote:
> Hi Erlang Developers'
> I'm stuck here, I am trying to print date which is in this format
> "2012/04/23" using io:format/2, but I want it to be printed like this:
> 2012/04/23 without invited commas, how do I go about resolving this?
> I'm stuck here, I am trying to print date which is in this format "2012/04/23" using io:format/2, but I want it to be printed like this: 2012/04/23 without invited commas, how do I go about resolving this?
Ask yourself, "how did those quotation marks get there? What did I to that
made io:format/2 think I was ASKING for them?"
It looks to me as though you used ~p when you meant ~s,
and in particular it looks to me as though you very likely
just want to do
io:put_chars(IoDevice, "2012/04/23")
and not involve io:format/2 at all. (Like in C you'd use fputs() rather
than fprintf().)
1> io:format(standard_io, "~p~n", ["2012/04/23"]).
"2012/04/23"
ok
2> io:format(standard_io, "~s~n", ["2012/04/23"]). 2012/04/23
ok
3> io:put_chars(standard_io, "2012/04/23"), io:nl(standard_io).
2012/04/23
ok
Before posting one more question, PLEASE try reading the manual.
Why not encourage users of Erlang, and just help them out, or ignore those questions that you deem to "easy" to be allowed to be asked on the mailing list.
There is really no reason to shout at a potential Erlang user of the year, just because he/she is just starting out with the language and does not know the ropes yet. Maybe its her first language? first time trying to program anything?, do you want to be responsible for scaring users away from the community?
>> I'm stuck here, I am trying to print date which is in this format "2012/04/23" using io:format/2, but I want it to be printed like this: 2012/04/23 without invited commas, how do I go about resolving this?
> READ THE MANUAL!
> Ask yourself, "how did those quotation marks get there? What did I to that
> made io:format/2 think I was ASKING for them?"
> It looks to me as though you used ~p when you meant ~s,
> and in particular it looks to me as though you very likely
> just want to do
> io:put_chars(IoDevice, "2012/04/23")
> and not involve io:format/2 at all. (Like in C you'd use fputs() rather
> than fprintf().)
> 1> io:format(standard_io, "~p~n", ["2012/04/23"]).
> "2012/04/23"
> ok
> 2> io:format(standard_io, "~s~n", ["2012/04/23"]).
> 2012/04/23
> ok
> 3> io:put_chars(standard_io, "2012/04/23"), io:nl(standard_io).
> 2012/04/23
> ok
> Before posting one more question, PLEASE try reading the manual.
----- Original Message -----
> From: Henrik Nord <hen...@erlang.org>
> To: Richard O'Keefe <o...@cs.otago.ac.nz>
> Cc: "erlang-questi...@erlang.org" <erlang-questi...@erlang.org>
> Sent: Thursday, November 15, 2012 3:06 PM
> Subject: Re: [erlang-questions] Print Date
> Hi
> Why not encourage users of Erlang, and just help them out, or ignore > those questions that you deem to "easy" to be allowed to be asked on > the > mailing list.
> There is really no reason to shout at a potential Erlang user of the > year, just because he/she is just starting out with the language and > does not know the ropes yet. Maybe its her first language? first time > trying to program anything?, do you want to be responsible for scaring > users away from the community?
> On 2012-11-14 23:25, Richard O'Keefe wrote:
>> On 15/11/2012, at 5:06 AM, Lucky wrote:
>>> Hi Erlang Developers'
>>> I'm stuck here, I am trying to print date which is in this format > "2012/04/23" using io:format/2, but I want it to be printed like this: > 2012/04/23 without invited commas, how do I go about resolving this?
>> READ THE MANUAL!
>> Ask yourself, "how did those quotation marks get there? What did I to > that
>> made io:format/2 think I was ASKING for them?"
>> It looks to me as though you used ~p when you meant ~s,
>> and in particular it looks to me as though you very likely
>> just want to do
>> io:put_chars(IoDevice, "2012/04/23")
>> and not involve io:format/2 at all. (Like in C you'd use fputs() > rather
>> than fprintf().)
>> 1> io:format(standard_io, "~p~n", ["2012/04/23"]).
>> "2012/04/23"
>> ok
>> 2> io:format(standard_io, "~s~n", ["2012/04/23"]).
>> 2012/04/23
>> ok
>> 3> io:put_chars(standard_io, "2012/04/23"), > io:nl(standard_io).
>> 2012/04/23
>> ok
>> Before posting one more question, PLEASE try reading the manual.
> Why not encourage users of Erlang, and just help them out, or ignore those questions that you deem to "easy" to be allowed to be asked on the mailing list.
> There is really no reason to shout at a potential Erlang user of the year, just because he/she is just starting out with the language and does not know the ropes yet. Maybe its her first language? first time trying to program anything?, do you want to be responsible for scaring users away from the community?
> On 2012-11-14 23:25, Richard O'Keefe wrote:
>> On 15/11/2012, at 5:06 AM, Lucky wrote:
>>> Hi Erlang Developers'
>>> I'm stuck here, I am trying to print date which is in this format "2012/04/23" using io:format/2, but I want it to be printed like this: 2012/04/23 without invited commas, how do I go about resolving this?
>> READ THE MANUAL!
>> Ask yourself, "how did those quotation marks get there? What did I to that
>> made io:format/2 think I was ASKING for them?"
>> It looks to me as though you used ~p when you meant ~s,
>> and in particular it looks to me as though you very likely
>> just want to do
>> io:put_chars(IoDevice, "2012/04/23")
>> and not involve io:format/2 at all. (Like in C you'd use fputs() rather
>> than fprintf().)
>> 1> io:format(standard_io, "~p~n", ["2012/04/23"]).
>> "2012/04/23"
>> ok
>> 2> io:format(standard_io, "~s~n", ["2012/04/23"]).
>> 2012/04/23
>> ok
>> 3> io:put_chars(standard_io, "2012/04/23"), io:nl(standard_io).
>> 2012/04/23
>> ok
>> Before posting one more question, PLEASE try reading the manual.
"Installing applications can lead to corruption over time. Applications gradually write over each other's libraries, partial upgrades occur, user and system errors happen, and minute changes may be unnoticeable and difficult to fix"