#!/usr/bin/env ascript
tester(test):map:dynamic_scope = printf("%s .. %s\n", test, eval(test)):nomap

lambda {
	A = class {
		__init__(name:string) = { self.name = name }
		func(str:string):map = println(self.name, ' ', str)
	}
	tbl = [A('abc'), A('def'), A('ghi'), A('jkl'), A('mno')]
	tbl::func('123')
	println('-----')
	tbl:*func('123').each():list
	println('-----')
	tbl:&func('123')
	println('-----')
	tbl::func(['123', '456', '789'])
	println('-----')
	tbl:*func(['123', '456', '789']).each():list
	println('-----')
	tbl:&func(['123', '456', '789'])
	println('-----')
	tbl.each():&func(['123', '456', '789']).each():list
	println('-----')
	tbl:&func(['123', '456', '789', '012', '345', '678', '901'])
	println('-----')
	tbl.each():&func(['123', '456', '789', '012', '345', '678', '901']).each():list
}()
lambda {
	strs = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
	strs:*x = strs:*len()
	strs::y = strs:*len()
	println(strs:*x.join(','))
	println(strs:*y.join(','))
}()
lambda {
	tester(`(math.sin(interval(0, math.pi / 2, 20)):list))
	tester(`(format("%.3f", math.sin(interval(0, math.pi / 2, 20)):list)))
	tester(`format("%d ** 2 = %d\n", [0..10], [0..10] ** 2))
	tester(`string.join(string.strip(string.split("  fj,  jfkdjfd,  dkfjdkj  ", ",")):list, ","))
}()
lambda {
	tester(test):map = printf("%-14s .. %s\n", test, eval(test)):nomap
	ident(x):map = x
	x = [nil, nil, 3, 1, 4, 1, nil, 5, nil, 9, 2, 6, 5, 3]
	tester(`x)
	tester(`ident(x))
	tester(`ident(x):list)
	tester(`ident(x):xlist)
	tester(`ident(x):set)
	tester(`ident(x):xset)
	tester(`[ident(x):iter])
	tester(`[ident(x):xiter])
	x = [nil, nil, nil, nil, nil]
	tester(`x)
	tester(`ident(x))
	tester(`ident(x):list)
	tester(`ident(x):xlist)
	tester(`ident(x):set)
	tester(`ident(x):xset)
	tester(`[ident(x):iter])
	tester(`[ident(x):xiter])
	x = [nil, nil, nil, nil, nil, 5]
	tester(`x)
	tester(`ident(x))
	tester(`ident(x):list)
	tester(`ident(x):xlist)
	tester(`ident(x):set)
	tester(`ident(x):xset)
	tester(`[ident(x):iter])
	tester(`[ident(x):xiter])
	x = [1, 2, [3, 4, [5, 6], 7, 8, [9, 10, [11, 12], 13, 14, 15]]]
	tester(`ident(x):flat)
	x = [nil, [nil, 3, [1, 4, 1, nil], 5, nil], 9, 2, 6, 5, 3]
	tester(`ident(x):flat)
	tester(`ident(x):flat:list)
	tester(`ident(x):flat:xlist)
	tester(`ident(x):flat:set)
	tester(`ident(x):flat:xset)
	x = [nil, nil, nil, nil, nil]
	tester(`ident(x):flat)
	tester(`ident(x):flat:list)
	tester(`ident(x):flat:xlist)
	tester(`ident(x):flat:set)
	tester(`ident(x):flat:xset)
	x = [nil, nil, nil, nil, nil, 5]
	tester(`ident(x):flat)
	tester(`ident(x):flat:list)
	tester(`ident(x):flat:xlist)
	tester(`ident(x):flat:set)
	tester(`ident(x):flat:xset)
}()
