Class: Egison::List

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

Class Method Summary collapse

Class Method Details

.uncons(val) ⇒ Object



30
31
32
33
34
# File 'lib/egison/matcher-core.rb', line 30

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

.uncons_stream(val, &block) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/egison/matcher-core.rb', line 36

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



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/egison/matcher-core.rb', line 45

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



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/egison/matcher-core.rb', line 59

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