[erlang-questions] how to make beautifulll code of this working code
Mon Aug 10 20:38:33 CEST 2015
On Mon, Aug 10, 2015 at 7:25 PM, Garrett Smith <g@REDACTED> wrote:
> Personally I find the Erlang docs excellent, so this:
> Roelof, I recommend that you spend some cycles reading these as a
> matter of course when you're using a function. The docs will help you
> get things right and you'll start to absorb some Erlang zen. The list
> is great to help after you've done that and still have questions.
My goodness reading the manual first. I thought this was the
only done when evoking the "if all else fails read the friendly manual bit"
I usually poke around in the shell first.
Not having a clue how re:split worked I guessed and tried this:
One wild guess later (and some distant memory) I tried
Life is too short to waste it reading manual pages - or is it the other way
around - life is too short to waste it by not reading manual pages - I
can'tmake my mind up
> This link provides an index, which might also be helpful for finding
> the right module and function in the first place:
> On Mon, Aug 10, 2015 at 11:33 AM, Garry Hodgson <garry@REDACTED> wrote:
>> right, because re.split() returns a list of binaries ( <<"2012">> )
>> where string:tokens() returns a list of strings ( "2012" ).
>> so you either need to see if you can convince re:split() to
>> return strings, or you need to coerce its output values
>> from binaries to lists prior to converting those lists to integers.
>> On 8/10/15 12:09 PM, Roelof Wobben wrote:
>>> Op 10-8-2015 om 17:59 schreef Garry Hodgson:
>>>> date_parts(Date) ->
>>>> [list_to_integer(N) || N <- string:tokens(Date,"-")].
>>> When testing I see this output:
>>> 2> dates:date_parts("2012-02-02").
>>> ** exception error: bad argument in function list_to_integer/1 called as
>>> list_to_integer(<<"2012">>) in call from dates:'-date_parts/1-lc$^0/1-0-'/1
>>> (dates.erl, line 6)
>>> Dit e-mailbericht is gecontroleerd op virussen met Avast
>>> erlang-questions mailing list
>> erlang-questions mailing list
> erlang-questions mailing list
More information about the erlang-questions