Module: Rbsiev::Primitives
- Includes:
- Arithmetic, Comparison, EmptyList
- Included in:
- Environment
- Defined in:
- lib/rbsiev/primitives.rb,
lib/rbsiev/primitives/arithmetic.rb,
lib/rbsiev/primitives/comparison.rb,
lib/rbsiev/primitives/empty_list.rb
Defined Under Namespace
Modules: Arithmetic, Comparison, EmptyList
Instance Method Summary
collapse
Methods included from Arithmetic
#add, #div, #mod, #mul, #subtract, #zero?
Methods included from Comparison
#ge?, #gt?, #le?, #lt?, #same_value?
Methods included from EmptyList
#null?
Instance Method Details
#append(*scm_lists) ⇒ Object
54
55
56
57
58
59
60
|
# File 'lib/rbsiev/primitives.rb', line 54
def append(*scm_lists)
if scm_lists.empty?
SCM_EMPTY_LIST
else
scm_lists[0] + append(*scm_lists[1..-1])
end
end
|
#car(scm_list) ⇒ Object
42
43
44
|
# File 'lib/rbsiev/primitives.rb', line 42
def car(scm_list)
scm_list[0]
end
|
#cdr(scm_list) ⇒ Object
46
47
48
|
# File 'lib/rbsiev/primitives.rb', line 46
def cdr(scm_list)
scm_list[1..-1]
end
|
#cons(scm_obj1, scm_obj2) ⇒ Object
30
31
32
|
# File 'lib/rbsiev/primitives.rb', line 30
def cons(scm_obj1, scm_obj2)
[scm_obj1, scm_obj2]
end
|
#display(scm_obj) ⇒ Object
66
67
68
69
|
# File 'lib/rbsiev/primitives.rb', line 66
def display(scm_obj)
write(scm_obj)
print "\n"
end
|
#list(*scm_objs) ⇒ Object
50
51
52
|
# File 'lib/rbsiev/primitives.rb', line 50
def list(*scm_objs)
scm_objs
end
|
#list?(scm_obj) ⇒ Boolean
38
39
40
|
# File 'lib/rbsiev/primitives.rb', line 38
def list?(scm_obj)
scm_obj.instance_of?(Array)
end
|
#number?(scm_obj) ⇒ Boolean
71
72
73
|
# File 'lib/rbsiev/primitives.rb', line 71
def number?(scm_obj)
scm_obj.kind_of?(Numeric) ? SCM_TRUE : SCM_FALSE
end
|
#pair?(scm_obj) ⇒ Boolean
34
35
36
|
# File 'lib/rbsiev/primitives.rb', line 34
def pair?(scm_obj)
scm_obj.instance_of?(Array)
end
|
#write(scm_obj) ⇒ Object
62
63
64
|
# File 'lib/rbsiev/primitives.rb', line 62
def write(scm_obj)
print scm_obj
end
|