View Problem

Split a list of things into numbers and non-numbers

Given a list that might contain e.g. a string, an integer, a float and a date,
split the list into numbers and non-numbers.
DiskEdit
python
import re
data = '34234aff340980adf0e0fa0fefl' ## or ''.join(array)

nonDigits = re.findall(re.compile('\D'), data)
digits = re.findall(re.compile('\d'), data)


DiskEdit
erlang
% Wrapped call to the auxiliary function
number_split(Xs) ->
number_split(Xs, [], []).

% The auxiliary function
number_split([], Num, NonNum) ->
{Num, NonNum};
number_split([X|Xs], Num, NonNum) ->
case is_number(X) of
true ->
number_split(Xs, [X|Num], NonNum);
false ->
number_split(Xs, Num, [X|NonNum])
end.
DiskEdit
erlang
List = ["hello", 25, 3.14, calendar:local_time()],
{Numbers, NonNumbers} = lists:partition(fun(E) -> is_number(E) end, List)

Submit a new solution for python or erlang
There are 17 other solutions in additional languages (clojure, cpp, csharp, fantom ...)