Sha256: 2261cda89f639bd5444b39d645bdacc3a82e4206d7e7a81b677783aa671942d5

Contents?: true

Size: 1010 Bytes

Versions: 3

Compression:

Stored size: 1010 Bytes

Contents

module PLang
  module VM
    class PLambda < Proc
            
      def call?(params)
        _call?(params, @form||[])
      end
      
      def _call?(params, form)
        if form.length == params.length
          form.each_with_index do |f, i|
            if f
              case f.type
                when :integer, :decimal, :char, :string
                  if f.type == params[i].id
                    unless f.value == params[i].params[0]
                      return false
                    end
                  end
                when :object
                  unless f.id.value == params[i].id
                    return false
                  else
                    unless _call?(params[i].params, f.params)
                      return false
                    end
                  end
              end
            end
          end
          return true
        else
          return false
        end
      end
      
      def form
        @form ||= []
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
p-lang-0.3.1 lib/vm/plambda.rb
p-lang-0.3.0 lib/vm/plambda.rb
p-lang-0.2.0 lib/vm/plambda.rb