Sha256: 57c74291518bd760cff1f0dbf86ca4796213dadddae36a99b7fa22e154bb6884

Contents?: true

Size: 1000 Bytes

Versions: 4

Compression:

Stored size: 1000 Bytes

Contents

require 'qlang/api/matrix_api'
require 'qlang/api/vector_api'
require 'qlang/api/list_api'
require 'qlang/api/func_api'
require 'qlang/api/integral_api'

module Qlang
  module Api
    # TODO:
    class ::String
      def rm(str_or_rgx)
        gsub(str_or_rgx, '')
      end

      def rm!(str_or_rgx)
        gsub!(str_or_rgx, '')
        self
      end

      def rms!(*str_or_rgxs)
        str_or_rgxs.each do |str_or_rgx|
          rm!(str_or_rgx)
        end
        self
      end

      def split_by_sp
        split(/ +/)
      end

      # FIX:
      def equalize!
        rms!(/\A +/, / +\z/)
        if self =~ /\A\(/ && self =~ /\)\z/
          rms!(/\A\(/, /\)\z/)
          rms!(/\A +/, / +\z/)
        else
          self
        end
      end
    end

    class ::Matrix
      def to_q
        q_rows = rows.map { |row| row.join(' ') }.join('; ')
        "(#{q_rows})"
      end
    end

    class ::Vector
      def to_q
        "(#{elements.join(' ')})"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
qlang-0.0.27180000 lib/qlang/api.rb
qlang-0.0.27100000 lib/qlang/api.rb
qlang-0.0.27000000 lib/qlang/api.rb
qlang-0.0.27 lib/qlang/api.rb