[erlang-questions] Sunday puzzle - trying to improve my Erlang

Richard Carlsson richardc@REDACTED
Sun Jul 6 23:39:30 CEST 2008

Edwin Fine wrote:
> Richard,
> Lovely solution! It's stuff like this that helps newcomers to Erlang 
> like myself to learn how to write better Erlang.
> I'm curious, though; what is the reason for writing
> Qs = [integer_to_list(S) || S <- [X*X || X <- lists:seq(32,99)]]
> instead of
> Qs = [integer_to_list(X*X) || X <- lists:seq(32,99)]

None whatsoever. The person responsible should be keelhauled.
Oh, right... Sorry.

It's just a remnant of a refactoring. I started out working on
lists on the form [S div 1000, ..., S rem 10], but realized that
I could just use the lists of character codes instead. But I
didn't tidy up after changing to integer_to_list(S). Improved
version attached.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: solve.erl
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080706/4fa06734/attachment.ksh>

More information about the erlang-questions mailing list