

Perl 6 in 2010 - a retrospection - perlgeek
http://perlgeek.de/blog-en/perl-6/perl-6-in-2010.html

======
Luyt
I find the 'Perl6 Periodic Table of the Operators' an intriguing poster.
<http://www.ozonehouse.com/mark/periodic/>

~~~
colomon
Unfortunately it's about two years behind the language now. Otherwise I'd have
one hanging on my office wall...

------
bokchoi

       # Lazy list of Fibonacci numbers up to (but excluding) 100:
       my @fib := 1, 2, *+* ...^ * >= 100;

~~~
jparise
Here's a (rough) Python equivalent:

    
    
      from itertools import islice
    
      def fib():
          a, b = 0, 1
          while True:
              yield a
              a, b = b, a + b
    
      for k in islice(fib(), 1, 100):
          print(k)
    

It uses a generator function to produce an infinite iterable sequence.
islice() is used to produce just a slice of that sequence.

This could probably be written using fewer characters, but I don't think it
could be anywhere near a short (and terse) as the Perl version.

~~~
masak
Correct me if I'm wrong, but that code prints 100 fibonacci numbers, whereas
the Perl 6 code prints all fibonacci numbers up to, but not including, 100.

~~~
jparise
You're right. I misread the range of the Perl version. Adjust the slice
accordingly.

~~~
masak
No, that's too easy a cop-out. :-) How would you stop at the right number in
Python code? Would you compute 100 numbers and then inspect/truncate
afterwards?

~~~
jparise
Ah, I see that I truly missed your earlier point. I suppose I would just do
this:

    
    
      def fib(max):
          a, b = 0, 1
          while a < max:
              yield a
              a, b = b, a + b
    
      for k in fib(100):
          print(k)

