module Rus3::Procedure::Predicate
Public Instance Methods
boolean?(obj)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 59 def boolean?(obj) obj.instance_of?(FalseClass) or obj.instance_of?(TrueClass) end
char?(obj)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 75 def char?(obj) obj.instance_of?(Rus3::Char) end
char_alphabetic?(char)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 210 def char_alphabetic?(char) Rus3::Char.alphabetic?(char) end
char_ci_eq?(char1, char2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 190 def char_ci_eq?(char1, char2) Rus3::Char.compare_chars(char1, char2, :==, ignore_case: true) end
char_ci_ge?(char1, char2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 206 def char_ci_ge?(char1, char2) Rus3::Char.compare_chars(char1, char2, :>=, ignore_case: true) end
char_ci_gt?(char1, char2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 198 def char_ci_gt?(char1, char2) Rus3::Char.compare_chars(char1, char2, :>, ignore_case: true) end
char_ci_le?(char1, char2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 202 def char_ci_le?(char1, char2) Rus3::Char.compare_chars(char1, char2, :<=, ignore_case: true) end
char_ci_lt?(char1, char2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 194 def char_ci_lt?(char1, char2) Rus3::Char.compare_chars(char1, char2, :<, ignore_case: true) end
char_eq?(char1, char2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 170 def char_eq?(char1, char2) Rus3::Char.compare_chars(char1, char2, :==) end
char_ge?(char1, char2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 186 def char_ge?(char1, char2) Rus3::Char.compare_chars(char1, char2, :>=) end
char_gt?(char1, char2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 178 def char_gt?(char1, char2) Rus3::Char.compare_chars(char1, char2, :>) end
char_le?(char1, char2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 182 def char_le?(char1, char2) Rus3::Char.compare_chars(char1, char2, :<=) end
char_lower_case?(letter)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 226 def char_lower_case?(letter) Rus3::Char.lower_case?(letter) end
char_lt?(char1, char2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 174 def char_lt?(char1, char2) Rus3::Char.compare_chars(char1, char2, :<) end
char_numeric?(char)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 214 def char_numeric?(char) Rus3::Char.numeric?(char) end
char_upper_case?(letter)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 222 def char_upper_case?(letter) Rus3::Char.upper_case?(letter) end
char_whitespace?(char)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 218 def char_whitespace?(char) Rus3::Char.whitespace?(char) end
complex?(num)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 117 def complex?(num) num.is_a?(Complex) || real?(num) end
eq?(obj1, obj2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 33 def eq?(obj1, obj2) obj1.equal?(obj2) end
eqv?(obj1, obj2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 29 def eqv?(obj1, obj2) obj1 == obj2 end
even?(n)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 159 def even?(n) raise Rus3::IntegerRequiredError, n unless integer?(n) n.even? end
input_port?(obj)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 299 def input_port?(obj) false end
integer?(num)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 129 def integer?(num) num.is_a?(Integer) end
list?(obj)
click to toggle source
Returns true if the arguemnt represents a list structure. Note that an empty list is a list.
# File lib/rus3/procedure/predicate.rb, line 12 def list?(obj) obj.instance_of?(Array) end
negative?(r)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 149 def negative?(r) raise Rus3::RealNumberRequiredError, r unless real?(r) r.negative? end
number?(obj)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 71 def number?(obj) obj.kind_of?(Numeric) end
odd?(n)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 154 def odd?(n) raise Rus3::IntegerRequiredError, n unless integer?(n) n.odd? end
output_port?(obj)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 303 def output_port?(obj) false end
pair?(obj)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 63 def pair?(obj) obj.instance_of?(Array) or obj.instance_of?(Rus3::Pair) end
port?(obj)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 88 def port?(obj) false end
positive?(r)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 144 def positive?(r) raise Rus3::RealNumberRequiredError, r unless real?(r) r.positive? end
procedure?(obj)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 92 def procedure?(obj) obj.instance_of?(Proc) end
rational?(num)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 125 def rational?(num) num.is_a?(Rational) || integer?(num) end
real?(num)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 121 def real?(num) num.is_a?(Float) || rational?(num) end
string?(obj)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 79 def string?(obj) obj.kind_of?(String) end
string_ci_eq?(str1, str2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 248 def string_ci_eq?(str1, str2) check_string(str1, str2) str1.downcase == str2.downcase end
string_ci_ge?(str1, str2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 288 def string_ci_ge?(str1, str2) check_string(str1, str2) str1.downcase >= str2.downcase end
string_ci_gt?(str1, str2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 278 def string_ci_gt?(str1, str2) check_string(str1, str2) str1.downcase > str2.downcase end
string_ci_le?(str1, str2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 283 def string_ci_le?(str1, str2) check_string(str1, str2) str1.downcase <= str2.downcase end
string_ci_lt?(str1, str2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 273 def string_ci_lt?(str1, str2) check_string(str1, str2) str1.downcase < str2.downcase end
string_eq?(str1, str2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 243 def string_eq?(str1, str2) check_string(str1, str2) str1 == str2 end
string_ge?(str1, str2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 268 def string_ge?(str1, str2) check_string(str1, str2) str1 >= str2 end
string_gt?(str1, str2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 258 def string_gt?(str1, str2) check_string(str1, str2) str1 > str2 end
string_le?(str1, str2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 263 def string_le?(str1, str2) check_string(str1, str2) str1 <= str2 end
string_lt?(str1, str2)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 253 def string_lt?(str1, str2) check_string(str1, str2) str1 < str2 end
symbol?(obj)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 67 def symbol?(obj) obj.instance_of?(Symbol) && obj != Rus3::UNDEF end
vector?(obj)
click to toggle source
procedure (R5RS/R7RS): (vector? obj)
# File lib/rus3/procedure/predicate.rb, line 84 def vector?(obj) obj.instance_of?(Rus3::Vector) end
zero?(z)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 139 def zero?(z) raise Rus3::NumberRequiredError, z unless number?(z) z.zero? end
Private Instance Methods
check_string(*objs)
click to toggle source
# File lib/rus3/procedure/predicate.rb, line 236 def check_string(*objs) objs.each { |obj| raise Rus3::StringRequiredError, obj unless string?(obj) } end