module List

Public Instance Methods

any_list?(seq) click to toggle source
# File lib/taxon/list.rb, line 14
def any_list?(seq)
  any_tuple?(seq) && has_matching_elements(seq)
end
has_matching_elements(seq) click to toggle source
# File lib/taxon/list.rb, line 9
def has_matching_elements(seq)
  type = seq[0].class
  seq.all?{|i| i.is_a?(type)}
end
list(data, pred) click to toggle source
# File lib/taxon/list.rb, line 26
def list(data, pred)
  if varying?(data, pred)
    send(pred, data) ? [data] : data
  else
    []
  end
end
list?(seq, pred=nil) click to toggle source
# File lib/taxon/list.rb, line 18
def list?(seq, pred=nil)
  if any_tuple?(seq)
    Taxon::Guard.predicate?(self, pred) ? seq.all?{|i| send(pred, i)} : any_list?(seq)
  else
    false
  end
end
multiple?(data, pred) click to toggle source
# File lib/taxon/list.rb, line 36
def multiple?(data, pred)
  list?(data, pred)
end
nothings?(data) click to toggle source
# File lib/taxon/list.rb, line 57
def nothings?(data)
  list?(data, :nothing?)
end
numbers?(data) click to toggle source
# File lib/taxon/list.rb, line 49
def numbers?(data)
  list?(data, :number?)
end
strings?(data) click to toggle source
# File lib/taxon/list.rb, line 53
def strings?(data)
  list?(data, :string?)
end
symbols?(data) click to toggle source
# File lib/taxon/list.rb, line 45
def symbols?(data)
  list?(data, :symbol?)
end
varying?(data, pred) click to toggle source
# File lib/taxon/list.rb, line 34
def varying?(data, pred)
  if Taxon::Guard.predicate?(self, pred)
    def multiple?(data, pred)
      list?(data, pred)
    end
    send(pred, data) || send(:multiple?, data, pred)
  else
    false
  end
end