[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] [ruby-talk:4931] Re: Perl 6 rumblings -- RFC 225 (v1) Data:Superpositions (fwd)



This looks like a well flung gauntlet for the wizards of AUTOLOAD (or
something)

Someone took the Perl 6 RFC 225 Data Superpositions paper and sent it to
ruby talk.

Matz the author of ruby promptly demonstrated the power and cleanness of
the Ruby iterators.

(Oh yes, that self.each construct iterates over any data structure 
primitive or libary or user that inherits the "Enumerable" mixin.)

John Carter

Work Email : john@netsys.co.za Private email : cyent@mweb.co.za 
Yell Phone : 083-543-6915      Phone         : 27-12-348-4246

Carter's Compass...

   I know I'm on the right track when by deleting code I'm adding
   functionality.
                  

---------- Forwarded message ----------
Date: Sat, 16 Sep 2000 09:22:37 +0900
From: Yukihiro Matsumoto <matz@zetabits.com>
Reply-To: ruby-talk@netlab.co.jp
To: ruby-talk ML <ruby-talk@netlab.co.jp>
Subject: [ruby-talk:4931] Re: Perl 6 rumblings -- RFC 225 (v1) Data:
    Superpositions

Hi,

In message "[ruby-talk:4930] Perl 6 rumblings -- RFC 225 (v1) Data: Superpositions"
    on 00/09/16, Conrad Schneiker <schneik@austin.ibm.com> writes:

|>         if (any(@value) < 10) { ... }
|> 
|> or:
|> 
|>         die unless all(@tests)->($data);
|> 
|> ought to be available to all Perl users.

This can be easily accomplished by the method like

  module Enumerable
    def any
      self.each do |item|
        return true if yield(item)
      end
      return false
    end
    def all
      self.each do |item|
        return false unless yield(item)
      end
      return true
    end
  end

  if tests.all{|x| x < 10} then
    ...
  end

Pretty easy huh?

							matz.



==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe