Class: Lab42::List
- Inherits:
-
Object
- Object
- Lab42::List
- Extended by:
- ClassMethods
- Includes:
- Enumerable
- Defined in:
- lib/lab42/list.rb,
lib/lab42/list/class_methods.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#car ⇒ Object
readonly
Returns the value of attribute car.
-
#cdr ⇒ Object
readonly
Returns the value of attribute cdr.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #caddr ⇒ Object
- #cadr ⇒ Object
- #cdddr ⇒ Object
- #cddr ⇒ Object
- #cons(new_head) ⇒ Object
- #deconstruct ⇒ Object
- #each(&blk) ⇒ Object
- #empty? ⇒ Boolean
Methods included from ClassMethods
Instance Attribute Details
#car ⇒ Object (readonly)
Returns the value of attribute car.
8 9 10 |
# File 'lib/lab42/list.rb', line 8 def car @car end |
#cdr ⇒ Object (readonly)
Returns the value of attribute cdr.
8 9 10 |
# File 'lib/lab42/list.rb', line 8 def cdr @cdr end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
8 9 10 |
# File 'lib/lab42/list.rb', line 8 def length @length end |
Instance Method Details
#==(other) ⇒ Object
10 11 12 13 14 |
# File 'lib/lab42/list.rb', line 10 def ==(other) = self.class.list?(other) && length == other.length && car == other.car && cdr == other.cdr |
#caddr ⇒ Object
18 |
# File 'lib/lab42/list.rb', line 18 def caddr = cdr.cdr.car |
#cadr ⇒ Object
16 |
# File 'lib/lab42/list.rb', line 16 def cadr = cdr.car |
#cdddr ⇒ Object
22 |
# File 'lib/lab42/list.rb', line 22 def cdddr = cdr.cdr.cdr |
#cddr ⇒ Object
20 |
# File 'lib/lab42/list.rb', line 20 def cddr = cdr.cdr |
#cons(new_head) ⇒ Object
24 |
# File 'lib/lab42/list.rb', line 24 def cons(new_head) = self.class.cons(new_head, self) |
#deconstruct ⇒ Object
26 |
# File 'lib/lab42/list.rb', line 26 def deconstruct = [car, cdr] |
#each(&blk) ⇒ Object
28 |
# File 'lib/lab42/list.rb', line 28 def each(&blk) = self.class.each(self, &blk) |
#empty? ⇒ Boolean
30 |
# File 'lib/lab42/list.rb', line 30 def empty? = false |