Skip to content

Instantly share code, notes, and snippets.

@lnds
Created January 12, 2016 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lnds/297bfd90aef441a0641c to your computer and use it in GitHub Desktop.
Save lnds/297bfd90aef441a0641c to your computer and use it in GitHub Desktop.
toques y famas en erlang
contar_toques_y_famas(Num,Sec) -> tyf(Num,Sec,Sec).
tyf([],_,_) -> {0,0};
tyf([HNS|TNS],[HXS|TXS],YS) ->
{T,F} = tyf(TNS,TXS,YS),
if HNS =:= HXS -> {T,F+1};
HNS =/= HXS -> {T+toque(HNS,YS),F}
end.
toque(X,XS) -> IN = lists:member(X,XS), if IN =:= true -> 1; IN =:= false -> 0 end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment