Sha256: 2cf4f7e047486d2583f84a1561e5634862f3ad6a46c1cf987aeb6c3507cb95f4

Contents?: true

Size: 661 Bytes

Versions: 2

Compression:

Stored size: 661 Bytes

Contents

# frozen_string_literal: true

module Rus3
  module 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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rus3-0.2.1 lib/rus3/procedure/control.rb
rus3-0.2.0 lib/rus3/procedure/control.rb