[#83328] tcltklib and not init'ing tk — aakhter@... (Aamer Akhter)

Hello,

13 messages 2003/10/01

[#83391] mixing in class methods — "Mark J. Reed" <markjreed@...>

Okay, probably a dumb question, but: is there any way to define

22 messages 2003/10/01
[#83392] Re: mixing in class methods — Ryan Pavlik <rpav@...> 2003/10/01

On Thu, 2 Oct 2003 06:02:32 +0900

[#83397] Re: mixing in class methods — Gavin Sinclair <gsinclair@...> 2003/10/01

On Thursday, October 2, 2003, 7:08:00 AM, Ryan wrote:

[#83399] Re: mixing in class methods — "Mark J. Reed" <markjreed@...> 2003/10/02

On Thu, Oct 02, 2003 at 07:37:25AM +0900, Gavin Sinclair wrote:

[#83404] Re: mixing in class methods — "Gavin Sinclair" <gsinclair@...> 2003/10/02

> On Thu, Oct 02, 2003 at 07:37:25AM +0900, Gavin Sinclair wrote:

[#83416] C or C++? — "Joe Cheng" <code@...>

I'd like to start writing Ruby extensions. Does it make a difference

32 messages 2003/10/02
[#83435] Re: C or C++? — "Aleksei Guzev" <aleksei.guzev@...> 2003/10/02

[#83448] xml in Ruby — paul vudmaska <paul_vudmaska@...> 2003/10/02

The biggest problem i have with Ruby is the sleepness

[#83455] Re: xml in Ruby — Chad Fowler <chad@...> 2003/10/02

On Thu, 2 Oct 2003, paul vudmaska wrote:

[#83464] Re: xml in Ruby or no xml it's just a question — paul vudmaska <paul_vudmaska@...> 2003/10/02

>>--------

[#83470] Re: xml in Ruby — paul vudmaska <paul_vudmaska@...>

>>>

15 messages 2003/10/02

[#83551] xml + ruby — paul vudmaska <paul_vudmaska@...>

>>---------

20 messages 2003/10/03
[#83562] Re: xml + ruby — Austin Ziegler <austin@...> 2003/10/03

On Fri, 3 Oct 2003 16:11:46 +0900, paul vudmaska wrote:

[#83554] hash of hashes — Paul Argentoff <argentoff@...>

Hi all.

18 messages 2003/10/03

[#83675] fox-tool - interactive gui builder for fxruby — henon <user@...>

hi fellows,

15 messages 2003/10/05

[#83730] Re: Enumerable#inject is surprising me... — "Weirich, James" <James.Weirich@...>

> Does it surprise you?

17 messages 2003/10/06
[#83732] Re: Enumerable#inject is surprising me... — nobu.nokada@... 2003/10/07

Hi,

[#83801] Extension Language for a Text Editor — Nikolai Weibull <ruby-talk@...>

OK. So I'm going to write a text editor for my masters' thesis. The

35 messages 2003/10/08
[#83803] Re: Extension Language for a Text Editor — Ryan Pavlik <rpav@...> 2003/10/08

On Thu, 9 Oct 2003 05:06:32 +0900

[#83806] Re: Extension Language for a Text Editor — Nikolai Weibull <ruby-talk@...> 2003/10/08

* Ryan Pavlik <rpav@mephle.com> [Oct, 08 2003 22:30]:

[#83812] Re: Extension Language for a Text Editor — Ryan Pavlik <rpav@...> 2003/10/08

On Thu, 9 Oct 2003 06:09:29 +0900

[#83955] Re: Extension Language for a Text Editor — Nikolai Weibull <ruby-talk@...> 2003/10/09

* Ryan Pavlik <rpav@mephle.com> [Oct, 09 2003 09:10]:

[#84169] General Ruby Programming questions — Simon Kitching <simon@...>

21 messages 2003/10/15
[#84170] Re: General Ruby Programming questions — Florian Gross <flgr@...> 2003/10/15

Simon Kitching wrote:

[#84172] Re: General Ruby Programming questions — Simon Kitching <simon@...> 2003/10/15

Hi Florian..

[#84331] Re: Email Harvesting — Greg Vaughn <gvaughn@...>

Ryan Dlugosz said:

17 messages 2003/10/21
[#84335] Re: Email Harvesting — Hugh Sasse Staff Elec Eng <hgs@...> 2003/10/21

On Wed, 22 Oct 2003, Greg Vaughn wrote:

[#84343] Re: Email Harvesting — Ruben Vandeginste <Ruben.Vandeginste@...> 2003/10/22

On Wed, 22 Oct 2003 08:35:32 +0900, Hugh Sasse Staff Elec Eng

[#84341] Ruby-oriented Linux distro? — Hal Fulton <hal9000@...>

There's been some talk of something like this in the past.

15 messages 2003/10/22
[#84348] Re: Ruby-oriented Linux distro? — Gavin Sinclair <gsinclair@...> 2003/10/22

On Wednesday, October 22, 2003, 6:01:16 PM, Hal wrote:

[#84351] Re: Ruby-oriented Linux distro? — Andrew Walrond <andrew@...> 2003/10/22

On Wednesday 22 Oct 2003 11:02 am, Gavin Sinclair wrote:

[#84420] Struggling with variable arguments to block — "Gavin Sinclair" <gsinclair@...>

Hi -talk,

18 messages 2003/10/24
[#84428] Re: Struggling with variable arguments to block — matz@... (Yukihiro Matsumoto) 2003/10/24

Hi,

[#84604] ruby-dev summary 21637-21729 — Takaaki Tateishi <ttate@...>

Hello,

21 messages 2003/10/30
[#84787] Re: ruby-dev summary 21637-21729 — Paul Brannan <pbrannan@...> 2003/11/06

On Fri, Oct 31, 2003 at 07:01:28AM +0900, Takaaki Tateishi wrote:

[#84789] Re: ruby-dev summary 21637-21729 — matz@... (Yukihiro Matsumoto) 2003/11/06

Hi,

[#84792] Re: ruby-dev summary 21637-21729 — Paul Brannan <pbrannan@...> 2003/11/06

On Thu, Nov 06, 2003 at 11:17:59PM +0900, Yukihiro Matsumoto wrote:

[#84794] Re: ruby-dev summary 21637-21729 — matz@... (Yukihiro Matsumoto) 2003/11/06

Hi,

Re: map/collect iterating over multiple arrays/arguments

From: "Ara.T.Howard" <ahoward@...>
Date: 2003-10-08 17:49:42 UTC
List: ruby-talk #83793
On Wed, 8 Oct 2003, quent wrote:

> zoranlazarevic@yahoo.com (Zoran Lazarevic) wrote in message news:<32c0bb6a.0310071950.55c75dd0@posting.google.com>...
>
> > Apparently it is not possible to iterate using Collection.each over
> > multiple collections. It is possible by using one thread per
> > collection, but I do not want to go there.
>
> a continuations multi_each has been placed on the wiki at rubygarden.org
> if you are interested

heres another one. it also defines an iterator class:


----CUT----
module Enumerable
  class Iterator
  public

    attr_reader :enumerable, :has_next

    def initialize enumerable, end_value = nil, &end_block
      @enumerable = enumerable
      @end_value = end_value
      @end_block = end_block
      initialize_fetch_block
    end

    def next
      @has_next ? fetch_next_element : fetch_end_value
    end

    def rewind
      initialize_fetch_block
      self
    end

  protected

    def initialize_fetch_block
      callcc do |@after_fetch|
	@has_next = true
	@enumerable.each do |@next_element|
	  callcc do |@next_fetch| @after_fetch.call end
	end
	@has_next = false
	@next_fetch = nil
	@after_fetch.call
      end
      @after_fetch = nil
    end

    def fetch_next_element
      result = @next_element
      callcc do |@after_fetch| @next_fetch.call end
      @after_fetch = nil
      result
    end

    def fetch_end_value
      @end_block ? @end_block.call : @end_value
    end
  end

  # enumerable instance methods
  def iterator; @iterator = Iterator.new self; end

  # enumerables class methods
  class << self
    def each(*enumerables, &block)
      iterators = enumerables.collect{|e| e.iterator}
      while true
        args = iterators.collect{|i| i.next}
        if args.detect{|arg| arg}
          block.call *args
        else
          return enumerables
        end
      end
    end
    def collect(*enumerables, &block)
      ret = []
      each(*enumerables){|*args| ret << (block.call *args)}
      ret
    end
    alias map collect
  end
end

if $0 == __FILE__
  a = ['fee','fie','foe','fum']
  h = {'k' => 'v', 'K' => 'V'}

  ai = a.iterator
  hi = h.iterator

  while ((n = ai.next)) do
    puts n.inspect
  end

  while ((n = hi.next)) do
    puts n.inspect
  end

  Enumerable::each a, h do |elem, kv|
    puts elem.inspect
    puts kv.inspect
  end

  p Enumerable::collect(a,h){|e,kv| [e,kv]}
end


__END__

OUTPUT:

"fee"
"fie"
"foe"
"fum"
["K", "V"]
["k", "v"]
"fee"
["K", "V"]
"fie"
["k", "v"]
"foe"
nil
"fum"
nil
[["fee", ["K", "V"]], ["fie", ["k", "v"]], ["foe", nil], ["fum", nil]]
----CUT----


-a
  ====================================
  | Ara Howard
  | NOAA Forecast Systems Laboratory
  | Information and Technology Services
  | Data Systems Group
  | R/FST 325 Broadway
  | Boulder, CO 80305-3328
  | Email: ara.t.howard@noaa.gov
  | Phone:  303-497-7238
  | Fax:    303-497-7259
  | The difference between art and science is that science is what we understand
  | well enough to explain to a computer.  Art is everything else.
  |   -- Donald Knuth, "Discover"
  | ~ > /bin/sh -c 'for lang in ruby perl; do $lang -e "print \"\x3a\x2d\x29\x0a\""; done'
  ====================================

In This Thread

Prev Next