#SRC: JCON
#
#  test various numbers of args

procedure main()
   local plist, alist, e

   plist := [3, -2, "image", proc("~===", 2), 
      p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12]

   every write((!plist)())
   every write((!plist)(1))
   every write((!plist)(1, 2))
   every write((!plist)(1, 2, 3))
   every write((!plist)(1, 2, 3, 4))
   every write((!plist)(1, 2, 3, 4, 5))
   every write((!plist)(1, 2, 3, 4, 5, 6))
   every write((!plist)(1, 2, 3, 4, 5, 6, 7))
   every write((!plist)(1, 2, 3, 4, 5, 6, 7, 8))
   every write((!plist)(1, 2, 3, 4, 5, 6, 7, 8, 9))
   every write((!plist)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))
   every write((!plist)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11))
   every write((!plist)(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12))

   alist := []
   while *alist < 14 do {
       every write((!plist) ! alist)
       put(alist, *alist + 1)
   }
end



#  p0 through p12 do their own output and then fail

procedure p0()
   note("p0")
end

procedure p1(a)
   note("p1", a)
end

procedure p2(a, b)
   note("p2", a, b)
end

procedure p3(a, b, c)
   note("p3", a, b, c)
end

procedure p4(a, b, c, d)
   note("p4", a, b, c, d)
end

procedure p5(a, b, c, d, e)
   note("p5", a, b, c, d, e)
end

procedure p6(a, b, c, d, e, f)
   note("p6", a, b, c, d, e, f)
end

procedure p7(a, b, c, d, e, f, g)
   note("p7", a, b, c, d, e, f, g)
end

procedure p8(a, b, c, d, e, f, g, h)
   note("p8", a, b, c, d, e, f, g, h)
end

procedure p9(a, b, c, d, e, f, g, h, i)
   note("p9", a, b, c, d, e, f, g, h, i)
end

procedure p10(a, b, c, d, e, f, g, h, i, j)
   note("p10", a, b, c, d, e, f, g, h, i, j)
end

procedure p11(a, b, c, d, e, f, g, h, i, j, k)
   note("p11", a, b, c, d, e, f, g, h, i, j, k)
end

procedure p12(a, b, c, d, e, f, g, h, i, j, k, l)
   note("p12", a, b, c, d, e, f, g, h, i, j, k, l)
end



procedure note(a[])
   local e

   every e := !a do writes(\e | "~", " ")
   write()
   return
end
