<commit_before>class LinkedList
  # By implementing LinkedList#each, we can include Enumerable
  include Enumerable

  attr_reader :head, :tail

  def initialize
    @head = Node.new(nil)
    @tail = nil
  end

  # O(1) time
  # prepend/add node to front/biginning of LL
  def unshift(value)
    new_node = Node(value)

    new_node.next = @head
    @head = new_node

    self
  end

  # O(1) time
  # remove node from front/biginning of LL
  def shift
    result = @head.value
    @head = Node(@head.next)
    result
  end

  # O(1) time
  # add node to end of LL
  # def push(value)
  #   new_tail = Node(value)
  #   @tail.next = new_tail
  #   @tail = new_tail

  #   self
  # end

  # O(1) time
  def empty?
    self.head.empty?
  end

  def each(&block)
    node = self.head

    until node.empty?
      block.call(node.value)
      node = node.next
    end

    self
  end

end

# This allows us to call Node(value) and is different
# than the class "Node".  This is how Ruby methods
# like Integer(value), Array(value), String(value), etc.
# work.
def Node(value)
  case value
  when Node
    value
  else
    Node.new(value)
  end
end

class Node
  include Enumerable

  attr_accessor :value, :next<commit_msg>reverse linked list done<commit_after>class LinkedList
  # By implementing LinkedList#each, we can include Enumerable
  include Enumerable

  attr_reader :head, :tail

  def initialize
    @head = Node.new(nil)
    @tail = nil
  end

  # O(1) time
  # prepend/add node to front/biginning of LL
  def unshift(value)
    new_node = Node(value)

    new_node.next = @head
    @head = new_node

    self
  end

  # O(1) time
  # remove node from front/biginning of LL
  def shift
    result = @head.value
    @head = Node(@head.next)
    result
  end

  # O(1) time
  # add node to end of LL
  # def push(value)
  #   new_tail = Node(value)
  #   @tail.next = new_tail
  #   @tail = new_tail

  #   self
  # end

  # O(1) time
  def empty?
    self.head.empty?
  end

  def each(&block)
    node = self.head

    until node.empty?
      block.call(node.value)
      node = node.next
    end

    self
  end

  def reverse
    new_linked_list = LinkedList.new
    self.each { |list| new_linked_list.unshift(list) }
    new_linked_list
  end

end

# This allows us to call Node(value) and is different
# than the class "Node".  This is how Ruby methods
# like Integer(value), Array(value), String(value), etc.
# work.
def Node(value)
  case value
  when Node
    value
  else
    Node.new(value)
  end
end

class Node
  include Enumerable

  attr_accessor :value, :next
{'fraction_non_alphanumeric': 0.09217660728117738, 'fraction_numerical': 0.003098373353989156, 'mean_word_length': 2.5383561643835617, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7099007', 'n_tokens_mistral': 936, 'n_tokens_neox': 902, 'n_words': 279}