You are very close, but you have a couple of suspected functions:
- A second sentence with an argument is
[H|[]]not required, because the following sentences with arguments [H|T]will handle the case when Tthere is []. - , . , , ,
[H|even_print(T)], , . , . , io:format/2 , , .
, :
-module(e).
-export([even_print/1]).
even_print([])-> [];
even_print([H|T]) when H rem 2 /= 0 ->
even_print(T);
even_print([H|T]) ->
io:format("printing: ~p~n", [H]),
[H|even_print(T)].
Erlang, :
3> e:even_print(lists:seq(1,10)).
printing: 2
printing: 4
printing: 6
printing: 8
printing: 10
[2,4,6,8,10]
, io:format/2.