Module: Rus3::Procedure::Predicate
- Includes:
- EmptyList
- Included in:
- Evaluator::Environment, Control, List, Vector, Write
- Defined in:
- lib/rus3/procedure/predicate.rb
Constant Summary
Constants included from EmptyList
Instance Method Summary collapse
-
#boolean?(obj) ⇒ Boolean
:startdoc:.
- #char?(obj) ⇒ Boolean
- #char_alphabetic?(char) ⇒ Boolean
- #char_ci_eq?(char1, char2) ⇒ Boolean
- #char_ci_ge?(char1, char2) ⇒ Boolean
- #char_ci_gt?(char1, char2) ⇒ Boolean
- #char_ci_le?(char1, char2) ⇒ Boolean
- #char_ci_lt?(char1, char2) ⇒ Boolean
-
#char_eq?(char1, char2) ⇒ Boolean
:startdoc:.
- #char_ge?(char1, char2) ⇒ Boolean
- #char_gt?(char1, char2) ⇒ Boolean
- #char_le?(char1, char2) ⇒ Boolean
- #char_lower_case?(letter) ⇒ Boolean
- #char_lt?(char1, char2) ⇒ Boolean
- #char_numeric?(char) ⇒ Boolean
- #char_upper_case?(letter) ⇒ Boolean
- #char_whitespace?(char) ⇒ Boolean
-
#complex?(num) ⇒ Boolean
:startdoc:.
- #eq?(obj1, obj2) ⇒ Boolean
-
#eqv?(obj1, obj2) ⇒ Boolean
:startdoc:.
- #even?(n) ⇒ Boolean
-
#input_port?(obj) ⇒ Boolean
:startdoc:.
- #integer?(num) ⇒ Boolean
-
#list?(obj) ⇒ Boolean
Returns true if the arguemnt represents a list structure.
- #negative?(r) ⇒ Boolean
- #number?(obj) ⇒ Boolean
- #odd?(n) ⇒ Boolean
- #output_port?(obj) ⇒ Boolean
- #pair?(obj) ⇒ Boolean
- #port?(obj) ⇒ Boolean
- #positive?(r) ⇒ Boolean
- #procedure?(obj) ⇒ Boolean
- #rational?(num) ⇒ Boolean
- #real?(num) ⇒ Boolean
- #string?(obj) ⇒ Boolean
- #string_ci_eq?(str1, str2) ⇒ Boolean
- #string_ci_ge?(str1, str2) ⇒ Boolean
- #string_ci_gt?(str1, str2) ⇒ Boolean
- #string_ci_le?(str1, str2) ⇒ Boolean
- #string_ci_lt?(str1, str2) ⇒ Boolean
- #string_eq?(str1, str2) ⇒ Boolean
- #string_ge?(str1, str2) ⇒ Boolean
- #string_gt?(str1, str2) ⇒ Boolean
- #string_le?(str1, str2) ⇒ Boolean
- #string_lt?(str1, str2) ⇒ Boolean
- #symbol?(obj) ⇒ Boolean
-
#vector?(obj) ⇒ Boolean
procedure (R5RS/R7RS): (vector? obj).
-
#zero?(z) ⇒ Boolean
:startdoc:.
Methods included from EmptyList
Instance Method Details
#boolean?(obj) ⇒ Boolean
:startdoc:
59 60 61 |
# File 'lib/rus3/procedure/predicate.rb', line 59 def boolean?(obj) obj.instance_of?(FalseClass) or obj.instance_of?(TrueClass) end |
#char?(obj) ⇒ Boolean
75 76 77 |
# File 'lib/rus3/procedure/predicate.rb', line 75 def char?(obj) obj.instance_of?(Rus3::Char) end |
#char_alphabetic?(char) ⇒ Boolean
210 211 212 |
# File 'lib/rus3/procedure/predicate.rb', line 210 def char_alphabetic?(char) Rus3::Char.alphabetic?(char) end |
#char_ci_eq?(char1, char2) ⇒ Boolean
190 191 192 |
# 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) ⇒ Boolean
206 207 208 |
# 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) ⇒ Boolean
198 199 200 |
# 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) ⇒ Boolean
202 203 204 |
# 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) ⇒ Boolean
194 195 196 |
# 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) ⇒ Boolean
:startdoc:
170 171 172 |
# File 'lib/rus3/procedure/predicate.rb', line 170 def char_eq?(char1, char2) Rus3::Char.compare_chars(char1, char2, :==) end |
#char_ge?(char1, char2) ⇒ Boolean
186 187 188 |
# File 'lib/rus3/procedure/predicate.rb', line 186 def char_ge?(char1, char2) Rus3::Char.compare_chars(char1, char2, :>=) end |
#char_gt?(char1, char2) ⇒ Boolean
178 179 180 |
# File 'lib/rus3/procedure/predicate.rb', line 178 def char_gt?(char1, char2) Rus3::Char.compare_chars(char1, char2, :>) end |
#char_le?(char1, char2) ⇒ Boolean
182 183 184 |
# File 'lib/rus3/procedure/predicate.rb', line 182 def char_le?(char1, char2) Rus3::Char.compare_chars(char1, char2, :<=) end |
#char_lower_case?(letter) ⇒ Boolean
226 227 228 |
# File 'lib/rus3/procedure/predicate.rb', line 226 def char_lower_case?(letter) Rus3::Char.lower_case?(letter) end |
#char_lt?(char1, char2) ⇒ Boolean
174 175 176 |
# File 'lib/rus3/procedure/predicate.rb', line 174 def char_lt?(char1, char2) Rus3::Char.compare_chars(char1, char2, :<) end |
#char_numeric?(char) ⇒ Boolean
214 215 216 |
# File 'lib/rus3/procedure/predicate.rb', line 214 def char_numeric?(char) Rus3::Char.numeric?(char) end |
#char_upper_case?(letter) ⇒ Boolean
222 223 224 |
# File 'lib/rus3/procedure/predicate.rb', line 222 def char_upper_case?(letter) Rus3::Char.upper_case?(letter) end |
#char_whitespace?(char) ⇒ Boolean
218 219 220 |
# File 'lib/rus3/procedure/predicate.rb', line 218 def char_whitespace?(char) Rus3::Char.whitespace?(char) end |
#complex?(num) ⇒ Boolean
:startdoc:
117 118 119 |
# File 'lib/rus3/procedure/predicate.rb', line 117 def complex?(num) num.is_a?(Complex) || real?(num) end |
#eq?(obj1, obj2) ⇒ Boolean
33 34 35 |
# File 'lib/rus3/procedure/predicate.rb', line 33 def eq?(obj1, obj2) obj1.equal?(obj2) end |
#eqv?(obj1, obj2) ⇒ Boolean
:startdoc:
29 30 31 |
# File 'lib/rus3/procedure/predicate.rb', line 29 def eqv?(obj1, obj2) obj1 == obj2 end |
#even?(n) ⇒ Boolean
159 160 161 162 |
# File 'lib/rus3/procedure/predicate.rb', line 159 def even?(n) raise Rus3::IntegerRequiredError, n unless integer?(n) n.even? end |
#input_port?(obj) ⇒ Boolean
:startdoc:
299 300 301 |
# File 'lib/rus3/procedure/predicate.rb', line 299 def input_port?(obj) false end |
#integer?(num) ⇒ Boolean
129 130 131 |
# File 'lib/rus3/procedure/predicate.rb', line 129 def integer?(num) num.is_a?(Integer) end |
#list?(obj) ⇒ Boolean
Returns true if the arguemnt represents a list structure. Note that an empty list is a list.
12 13 14 |
# File 'lib/rus3/procedure/predicate.rb', line 12 def list?(obj) obj.instance_of?(Array) end |
#negative?(r) ⇒ Boolean
149 150 151 152 |
# File 'lib/rus3/procedure/predicate.rb', line 149 def negative?(r) raise Rus3::RealNumberRequiredError, r unless real?(r) r.negative? end |
#number?(obj) ⇒ Boolean
71 72 73 |
# File 'lib/rus3/procedure/predicate.rb', line 71 def number?(obj) obj.kind_of?(Numeric) end |
#odd?(n) ⇒ Boolean
154 155 156 157 |
# File 'lib/rus3/procedure/predicate.rb', line 154 def odd?(n) raise Rus3::IntegerRequiredError, n unless integer?(n) n.odd? end |
#output_port?(obj) ⇒ Boolean
303 304 305 |
# File 'lib/rus3/procedure/predicate.rb', line 303 def output_port?(obj) false end |
#pair?(obj) ⇒ Boolean
63 64 65 |
# File 'lib/rus3/procedure/predicate.rb', line 63 def pair?(obj) obj.instance_of?(Array) or obj.instance_of?(Rus3::Pair) end |
#port?(obj) ⇒ Boolean
88 89 90 |
# File 'lib/rus3/procedure/predicate.rb', line 88 def port?(obj) false end |
#positive?(r) ⇒ Boolean
144 145 146 147 |
# File 'lib/rus3/procedure/predicate.rb', line 144 def positive?(r) raise Rus3::RealNumberRequiredError, r unless real?(r) r.positive? end |
#procedure?(obj) ⇒ Boolean
92 93 94 |
# File 'lib/rus3/procedure/predicate.rb', line 92 def procedure?(obj) obj.instance_of?(Proc) end |
#rational?(num) ⇒ Boolean
125 126 127 |
# File 'lib/rus3/procedure/predicate.rb', line 125 def rational?(num) num.is_a?(Rational) || integer?(num) end |
#real?(num) ⇒ Boolean
121 122 123 |
# File 'lib/rus3/procedure/predicate.rb', line 121 def real?(num) num.is_a?(Float) || rational?(num) end |
#string?(obj) ⇒ Boolean
79 80 81 |
# File 'lib/rus3/procedure/predicate.rb', line 79 def string?(obj) obj.kind_of?(String) end |
#string_ci_eq?(str1, str2) ⇒ Boolean
248 249 250 251 |
# 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) ⇒ Boolean
288 289 290 291 |
# 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) ⇒ Boolean
278 279 280 281 |
# 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) ⇒ Boolean
283 284 285 286 |
# 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) ⇒ Boolean
273 274 275 276 |
# 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) ⇒ Boolean
243 244 245 246 |
# File 'lib/rus3/procedure/predicate.rb', line 243 def string_eq?(str1, str2) check_string(str1, str2) str1 == str2 end |
#string_ge?(str1, str2) ⇒ Boolean
268 269 270 271 |
# File 'lib/rus3/procedure/predicate.rb', line 268 def string_ge?(str1, str2) check_string(str1, str2) str1 >= str2 end |
#string_gt?(str1, str2) ⇒ Boolean
258 259 260 261 |
# File 'lib/rus3/procedure/predicate.rb', line 258 def string_gt?(str1, str2) check_string(str1, str2) str1 > str2 end |
#string_le?(str1, str2) ⇒ Boolean
263 264 265 266 |
# File 'lib/rus3/procedure/predicate.rb', line 263 def string_le?(str1, str2) check_string(str1, str2) str1 <= str2 end |
#string_lt?(str1, str2) ⇒ Boolean
253 254 255 256 |
# File 'lib/rus3/procedure/predicate.rb', line 253 def string_lt?(str1, str2) check_string(str1, str2) str1 < str2 end |
#symbol?(obj) ⇒ Boolean
67 68 69 |
# File 'lib/rus3/procedure/predicate.rb', line 67 def symbol?(obj) obj.instance_of?(Symbol) && obj != Rus3::UNDEF end |
#vector?(obj) ⇒ Boolean
procedure (R5RS/R7RS): (vector? obj)
84 85 86 |
# File 'lib/rus3/procedure/predicate.rb', line 84 def vector?(obj) obj.instance_of?(Rus3::Vector) end |
#zero?(z) ⇒ Boolean
:startdoc:
139 140 141 142 |
# File 'lib/rus3/procedure/predicate.rb', line 139 def zero?(z) raise Rus3::NumberRequiredError, z unless number?(z) z.zero? end |