Class: Object

Inherits:
BasicObject
Defined in:
lib/fr/thunk.rb,
lib/fr/object.rb

List Constructors collapse

Combinators collapse

Instance Method Summary collapse

Instance Method Details

#bind {|_self| ... } ⇒ Object

Yields ‘self` to a block argument

Examples:

nil.bind{|a| a.nil? }   #=> true
100.bind{|a| a.nil? }   #=> false

Yields:

  • (_self)

Yield Parameters:

  • _self (Object)

    the object that the method was called on



39
40
41
# File 'lib/fr/object.rb', line 39

def bind
  yield self
end

#cons(tail = []) ⇒ Array

Prepend the item to the front of a new list

Examples:

1.cons              #=> [1]
1.cons(2.cons)      #=> [1, 2]
1.cons([0, 0, 0])   #=> [1, 0, 0, 0]

Returns:



14
15
16
# File 'lib/fr/object.rb', line 14

def cons(tail = [])
  [self] + tail
end

#snoc(init = []) ⇒ Array

Append the item to rear of a new list

Examples:

1.snoc              #=> [1]
1.snoc(2.snoc)      #=> [2, 1]
1.snoc([0, 0, 0])   #=> [0, 0, 0, 1]

Returns:



26
27
28
# File 'lib/fr/object.rb', line 26

def snoc(init = [])
  init + [self]
end

#thunk?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/fr/thunk.rb', line 70

def thunk?
  false
end