Class: Egison::List

Inherits:
Object show all
Defined in:
lib/egison/matcher-core.rb

Class Method Summary collapse

Class Method Details

.uncons(val) ⇒ Object



64
65
66
67
68
# File 'lib/egison/matcher-core.rb', line 64

def uncons(val)
  val2 = val.clone
  x = val2.shift
  [[x, val2]]
end

.uncons_stream(val, &block) ⇒ Object



70
71
72
73
74
75
76
77
# File 'lib/egison/matcher-core.rb', line 70

def uncons_stream(val, &block)
  if !(val.kind_of?(Array) || val.kind_of?(Egison::LazyArray))
    val = test_conv_lazy_array(val)
  end
  val2 = val.clone
  x = val2.shift
  block.([x, val2])
end

.unjoin(val) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/egison/matcher-core.rb', line 79

def unjoin(val)
  val2 = val.clone
  xs = []
  ys = val2.clone
  rets = [[xs, ys]]
  until val2.empty? do
    x = val2.shift
    ys = val2.clone
    xs += [x]
    rets += [[xs, ys]]
  end
  rets
end

.unjoin_stream(val, &block) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/egison/matcher-core.rb', line 93

def unjoin_stream(val, &block)
  if !(val.kind_of?(Array) || val.kind_of?(Egison::LazyArray))
    val = test_conv_lazy_array(val)
  end
  val2 = val.clone
  xs = []
  ys = val2.clone
  block.([xs, ys])
  until val2.empty?
    x = val2.shift
    ys = val2.clone
    xs += [x]
    block.([xs, ys])
  end
end