[Rio-pm] [Golf] Fatorial

Daniel de Oliveira Mantovani daniel.oliveira.mantovani em gmail.com
Segunda Fevereiro 1 05:17:28 PST 2010


Olá pessoal, ontem eu li no Twitter esse link:
http://gist.github.com/290978

Entre as coisas que estavam escritas nesse link, tinha algo do tipo
#code golf programmer
print(($_=sub{$_[0]?($_[0]*$_->($_[0]-1)):1})->(6))

(Não sei pq isso não está mais lá, ontem estava)

Fazer fatorial usando Perl 5.10.* <

Eu fiz minha tacada:
perl -E 'sub f{$_[0]<=0?1:f($_[0]-1)*$_[0]}say f(6)'

Que comece o golf :)

-- 
"If you’ve never written anything thoughtful, then you’ve never had
any difficult, important, or interesting thoughts. That’s the secret:
people who don’t write, are people who don’t think."


Mais detalhes sobre a lista de discussão Rio-pm