 #
 # Copyright (c) 2011 Olaf Delgado-Friedrichs (odf@github.com)
 # --------------------------------------------------------------------
+
+
+if typeof(require) != 'undefined'
+  require.paths.unshift('#{__dirname}/../lib')
+  { Sequence } = require('sequence')
+else
+  { Sequence } = pazy
 
 
 # A node.

  reduceLeft  = (op) -> (z, x) -> x.reduceLeft(z, op)
  reduceRight = (op) -> (x, z) -> x.reduceRight(op, z)

  asTree = (s) -> reduceLeft((a, b) -> a.before b) Empty, s

  constructor: (left, mid, right) ->
    @l = left

    else
      new Deep @l, @m, @r.init()

  nodes = (n, s) ->
    if n == 0
      null
    else if n == 2 or n % 3 == 1
      Sequence.conj new Tree2(s.take(3).into([])...), -> nodes n-2, s.drop 2
    else if n >= 3
      Sequence.conj new Tree3(s.take(3).into([])...), -> nodes n-3, s.drop 3
    else
      raise new Error "this should not happen"


# --------------------------------------------------------------------
# Exporting.
