Sha256: 8d87aa354d2a7d013e49e7ad3b20c3242f60991441d1b31a0735ec967dc16e15

Contents?: true

Size: 591 Bytes

Versions: 3

Compression:

Stored size: 591 Bytes

Contents

# frozen_string_literal: true

module Rus3::Procedure
  module Control

    include Predicate
    include Rus3::EmptyList

    def map(prc, *lists)
      case lists.size
      when 0
        EMPTY_LIST
      when 1
        raise Rus3::ListRequiredError, lists[0] unless list?(lists[0])
        lists[0].map(&prc)
      else
        zip(*lists).map {|args|
          prc.call(*args)
        }
      end
    end

    def zip(*lists)
      case lists.size
      when 0
        EMPTY_LIST
      when 1
        lists[0]
      else
        lists[0].zip(*lists[1..-1])
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rus3-0.1.2 lib/rus3/procedure/control.rb
rus3-0.1.1 lib/rus3/procedure/control.rb
rus3-0.1.0 lib/rus3/procedure/control.rb