Created
March 1, 2016 08:15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% ... | |
read_array(0,D) -> []; | |
read_array(N,D) -> | |
{ok, [X]} = io:fread("", D), | |
[X | read_array(N-1,D)]. | |
read_2darray(0,M,D) -> []; | |
read_2darray(N,M,D) -> | |
Q=read_array(M,D), | |
[Q | read_2darray(N-1,M,D)]. | |
% This produces compiler warnings because the empty array case doesn't use the M or D variables: | |
% solution.erl:10: Warning: variable 'D' is unused | |
% solution.erl:15: Warning: variable 'D' is unused | |
% solution.erl:15: Warning: variable 'M' is unused | |
read_array(0,_M) -> []; | |
read_array(N,D) -> | |
{ok, [X]} = io:fread("", D), | |
[X | read_array(N-1,D)]. | |
read_2darray(0,_M,_D) -> []; | |
read_2darray(N,M,D) -> | |
Q=read_array(M,D), | |
[Q | read_2darray(N-1,M,D)]. | |
% This doesn't produce compiler warnings because the variables start with an underscore, | |
% but still denotes the "M" and the "N" for clarity. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment