Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#Languages: 5

Languages: 5

#Languages: 5

Languages: 5

Remove leftover debugging code from Erlang
Source Link
Mark
  • 2.4k
  • 17
  • 16

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")))).
Updated QBasic byte count, added Erlang
Source Link
Mark
  • 2.4k
  • 17
  • 16

#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.

Added Pascal
Source Link
Mark
  • 2.4k
  • 17
  • 16
Loading
Added QBasic in 97 bytes
Source Link
Mark
  • 2.4k
  • 17
  • 16
Loading
New version of the BASIC program that permits greater use of abbreviations and makes it look like line noise
Source Link
Mark
  • 2.4k
  • 17
  • 16
Loading
Source Link
Mark
  • 2.4k
  • 17
  • 16
Loading

AltStyle によって変換されたページ (->オリジナル) /