#Languages: 5
Languages: 5
#Languages: 5
Languages: 5
Erlang: 456401 bytes
-module(means).
-import(io).
-import(math).
-import(string).
-import(lists).
-export([means/6,means/1]6]).
means(S,N,Q,P,R,[]) -> io:fwrite("~f,~f,~f,~f,~f~n", [N/R,math:pow(P,(1/N)),S/N,math:sqrt(Q/N),Q/S]);
means(S,N,Q,P,R,[V|T]) -> means(S+V,N+1,Q+V*V,P*V,R+1/V,T).
means([H|T]) -> io:fwrite("~f~n", H),means(T).
means:means(0,0,0,1,0,lists:map(fun({F,R}) -> F end, lists:map(fun(X) -> string:to_float(X) end, string:tokens(io:get_line(""), ",\n")))).
Erlang: 456 bytes
-module(means).
-import(io).
-import(math).
-import(string).
-import(lists).
-export([means/6,means/1]).
means(S,N,Q,P,R,[]) -> io:fwrite("~f,~f,~f,~f,~f~n", [N/R,math:pow(P,(1/N)),S/N,math:sqrt(Q/N),Q/S]);
means(S,N,Q,P,R,[V|T]) -> means(S+V,N+1,Q+V*V,P*V,R+1/V,T).
means([H|T]) -> io:fwrite("~f~n", H),means(T).
means:means(0,0,0,1,0,lists:map(fun({F,R}) -> F end, lists:map(fun(X) -> string:to_float(X) end, string:tokens(io:get_line(""), ",\n")))).
Erlang: 401 bytes
-module(means).
-import(io).
-import(math).
-import(string).
-import(lists).
-export([means/6]).
means(S,N,Q,P,R,[]) -> io:fwrite("~f,~f,~f,~f,~f~n", [N/R,math:pow(P,(1/N)),S/N,math:sqrt(Q/N),Q/S]);
means(S,N,Q,P,R,[V|T]) -> means(S+V,N+1,Q+V*V,P*V,R+1/V,T).
means:means(0,0,0,1,0,lists:map(fun({F,R}) -> F end, lists:map(fun(X) -> string:to_float(X) end, string:tokens(io:get_line(""), ",\n")))).
#Languages: 45
QBasic: 9796 bytes
The input is separated by spaces, not commas, and is newline terminated. Output is space-separated.
Erlang: 456 bytes
-module(means).
-import(io).
-import(math).
-import(string).
-import(lists).
-export([means/6,means/1]).
means(S,N,Q,P,R,[]) -> io:fwrite("~f,~f,~f,~f,~f~n", [N/R,math:pow(P,(1/N)),S/N,math:sqrt(Q/N),Q/S]);
means(S,N,Q,P,R,[V|T]) -> means(S+V,N+1,Q+V*V,P*V,R+1/V,T).
means([H|T]) -> io:fwrite("~f~n", H),means(T).
means:means(0,0,0,1,0,lists:map(fun({F,R}) -> F end, lists:map(fun(X) -> string:to_float(X) end, string:tokens(io:get_line(""), ",\n")))).
String handling in Erlang is a royal pain. Consequently, all floating-point numbers must be entered with at least one digit after the decimal point -- string:to_float/1 will not convert 1, but will convert 1.0.
#Languages: 4
QBasic: 97 bytes
The input is separated by spaces, not commas, and is newline terminated. Output is space-separated.
#Languages: 5
QBasic: 96 bytes
The input is separated by spaces, not commas, and is newline terminated. Output is space-separated.
Erlang: 456 bytes
-module(means).
-import(io).
-import(math).
-import(string).
-import(lists).
-export([means/6,means/1]).
means(S,N,Q,P,R,[]) -> io:fwrite("~f,~f,~f,~f,~f~n", [N/R,math:pow(P,(1/N)),S/N,math:sqrt(Q/N),Q/S]);
means(S,N,Q,P,R,[V|T]) -> means(S+V,N+1,Q+V*V,P*V,R+1/V,T).
means([H|T]) -> io:fwrite("~f~n", H),means(T).
means:means(0,0,0,1,0,lists:map(fun({F,R}) -> F end, lists:map(fun(X) -> string:to_float(X) end, string:tokens(io:get_line(""), ",\n")))).
String handling in Erlang is a royal pain. Consequently, all floating-point numbers must be entered with at least one digit after the decimal point -- string:to_float/1 will not convert 1, but will convert 1.0.
- 2.4k
- 17
- 16