class String
Public Instance Methods
append_K(a)
click to toggle source
# File lib/m500.rb, line 236 def append_K(a) a = a.to_Frac self.gsub!("&&&&","Fraction(Zahlen(#{a.integer.to_s}),Quotient(Zahlen(#{a.properfraction.numerator.to_s}),Zahlen(#{a.properfraction.denominator.to_s})))") end
is_Dec?()
click to toggle source
# File lib/m500.rb, line 102 def is_Dec? t = true re = /(^-?[0-9]+)\\#{Decimal::decimalSeparator}([0-9]+)/ re = /(^-?[0-9]+)\.([0-9]+)/ md = re.match(self.to_s) if md.nil? t = false else t = false if md[1].nil? && md[2].nil? && md[3].nil? end t end
is_Frac?()
click to toggle source
# File lib/m500.rb, line 91 def is_Frac? t = true re = /(^-?[0-9]+) ([0-9]+)\/([0-9]+)/ md = re.match(self) if md.nil? t = false else t = false if md[1].nil? && md[2].nil? && md[3].nil? && md[4].nil? end t end
is_K?()
click to toggle source
# File lib/m500.rb, line 222 def is_K? t = true re = /(\d+)#{Kettenbruch::Separator}(\d+)/ md = re.match(self) t = false if md[1].nil? && md[2].nil? t end
is_K_Leicht?()
click to toggle source
# File lib/m500.rb, line 229 def is_K_Leicht? t = true re = /(\d+)#{Kettenbruch::Separator}(\d+)/ md = re.match(self) t = false if md[1].nil? && md[2].nil? t end
is_N0?()
click to toggle source
# File lib/m500.rb, line 68 def is_N0? re = /(^[0-9]+)$/ md = re.match(self.to_s) t = emptySet t = md[1].to_i.to_N unless md.nil? end
is_N?()
click to toggle source
# File lib/m500.rb, line 62 def is_N? re = /(^[0-9]+)$/ md = re.match(self.to_s) t = emptySet t = md[1].to_i.to_N unless md.nil? end
is_Q?()
click to toggle source
# File lib/m500.rb, line 41 def is_Q? t = true re = /(\d+)\/(\d+)/ md = re.match(self) if md.nil? then t = is_Z? else t = false if md[1].nil? && md[2].nil? && md[3].nil? && md[4].nil? end t end
is_R?()
click to toggle source
# File lib/m500.rb, line 116 def is_R? false end
is_Sig?()
click to toggle source
# File lib/m500.rb, line 114 def is_Sig? end
is_Z?()
click to toggle source
# File lib/m500.rb, line 74 def is_Z? re = /(^-?[0-9]+)$/ md = re.match(self.to_s) t = emptySet t = Zahlen(md[1].to_i) unless md.nil? end
is_f?()
click to toggle source
# File lib/m500.rb, line 55 def is_f? t = true re = /(\-*\d+).(\d+)e([-|+])(\d+)/ md = re.match(self) t = false if md[1].nil? && md[2].nil? && md[3].nil? && md[4].nil? t end
is_r?()
click to toggle source
# File lib/m500.rb, line 52 def is_r? Rational(self).kind_of?(Rational) end
to_Dec()
click to toggle source
# File lib/m500.rb, line 149 def to_Dec re = /^-/ md = re.match(self.to_s) e = -1 e = 1 if md.to_a.empty? md = nil t0 = 0 t1 = '0' t2 = nil t3 = nil re = /([0-9]+)#{Decimal::decimalSeparator}([0-9]+)\[([0-9]+)\]/ re = /([0-9]+)\.([0-9]+)\[([0-9]+)\]/ md = re.match(self.to_s) if md.to_a.empty? then re = /([0-9]+)#{Decimal::decimalSeparator}([0-9]+)/ re = /([0-9]+)\.([0-9]+)/ md = re.match(self.to_s) if md.to_a.empty? then re = /([0-9]+)#{Decimal::decimalSeparator}\[([0-9]+)\]/ re = /([0-9]+)\.\[([0-9]+)\]/ md = re.match(self.to_s) if md.to_a.empty? then re = /([0-9]+)/ md = re.match(self.to_s) t0 = 0 t1 = '0' t2 = nil t3 = md[1].to_i else t0 = 0 t1 = md[2] #.to_i t2 = nil t3 = md[1].to_i end else t0 = md[2].scan(/^0+/)[0].length unless md[2].scan(/^0+/).empty? t1 = md[3] unless md[3].nil? t2 = md[2].to_i t3 = md[1].to_i end else t0 = md[2].scan(/^0+/)[0].length unless md[2].scan(/^0+/).empty? t1 = md[3] unless md[3].nil? t2 = md[2].to_i t3 = md[1].to_i end Decimal(t3,t2,t1,t0,e) end
to_Frac()
click to toggle source
# File lib/m500.rb, line 197 def to_Frac re = /(^[0-9]+) ([0-9]+)\/([0-9]+)/ md = re.match(self.to_s) t = nil if not md.nil? then t = Fraction(Zahlen(md[1].to_i),Quotient(md[2].to_i, md[3].to_i)) else re = /^-1\(([0-9]+) ([0-9]+)\/([0-9]+)\)/ md = re.match(self.to_s) if not md.nil? then t = Fraction(Zahlen(md[1].to_i),Quotient(md[2].to_i, md[3].to_i),-1) unless md.nil? else re = /(\-*[0-9]+)\/([0-9]+)/ md = re.match(self.to_s) if not md.nil? then t = Fraction(Quotient(Zahlen(md[1].to_i),Natural(md[2].to_i))) else t=Fraction(Quotient(self.to_i,1)) end end end end
to_K()
click to toggle source
# File lib/m500.rb, line 240 def to_K a = self.split(";") int = a.at(0).to_i re = /'...'/ md = re.match(a.at(1)) frK = eval("[" + a.at(1).gsub("...","") + "]" ) ([int] + frK).to_K end
to_N()
click to toggle source
# File lib/m500.rb, line 119 def to_N re = /(^[0-9]+)/ md = re.match(self.to_s) t = emptySet t = md[1].to_i.to_N unless md.nil? end
to_N0()
click to toggle source
# File lib/m500.rb, line 125 def to_N0 re = /(^[0-9]+)/ md = re.match(self.to_s) t = emptySet t = md[1].to_i.to_N0 unless md.nil? end
to_Q()
click to toggle source
# File lib/m500.rb, line 137 def to_Q re = /(-?[0-9]+)\/([0-9]+)/ md = re.match(self.to_s) ret = emptySet if md then t = 1 Natural(md[2].to_i).kind_of?(EmptySetClass) ? ret = infinity : ret = Quotient(Zahlen(md[1].to_i),Natural(md[2].to_i)) else Natural(md[2].to_i).kind_of?(EmptySetClass) ? ret = infinity : ret = Quotient(Zahlen(md[1].to_i),Natural(md[2].to_i)) end ret end
to_ST()
click to toggle source
# File lib/m500.rb, line 219 def to_ST ST.new(self) end
to_Sig()
click to toggle source
# File lib/m500.rb, line 248 def to_Sig end
to_Z()
click to toggle source
# File lib/m500.rb, line 131 def to_Z re = /(^-?[0-9]+)/ md = re.match(self.to_s) t = emptySet t = Zahlen(md[1].to_i) unless md.nil? end