code written using the Perl programming
language will look for
duplicate words in a text document:
print "$.: doubled $_\n" while /\b(\w+)\b\s+\b\1\b/gi
Can you work out how Perl does this?
(In Perl’s defense, it is an amazingly powerful programming lan‐
guage with a different set of aims and objectives than Python. That’s
the point—you wouldn’t try to teach a person how to read with
James Joyce’s
Ulysses
, despite it being widely regarded as one of the
top English-language novels of the 20
th
century.)
Put simply, because you don’t have to concentrate
on how to read or
write Python code, you can put more effort into actually under‐
standing it. Anything that lowers the effort required to engage in
programming is a good thing in an educational context (actually,
one could argue that this is true in all contexts).
Do'stlaringiz bilan baham: