// Test various permutations of ?= proc iap(obj, cls) {return obj ?= cls;} proc main() { var typ = {Int, Float, Array[*], Array, String, PackInt, Array[2,3], String[3], PackInt[5]}; var cap = {" ", "Int", "Flt", "Arr*", "Arr", "Str", "PkI", "Arr23", "Str3", "Pki5"}; var val = {3, 4.0, {1,2}, nil.reshape(1,3), "hello", [1,2,3], nil.reshape(2,3), "lo!", [1,2,3,4,5]}; var str = {3, 4.0, "{1,2}", "nil.reshape(1,3)", "hello", "[1,2,3]", "nil.reshape(2,3)", "lo!", "[1,2,3,4,5]"}; var res = new Array(10,10); var outr; // Compute the outer product of the vals and the types outr = val.outer(iap, typ); // Create the formatted array res[0,0:] = cap; // First row is captions res[1:,0] = str; // First column is string vers of vars res[1:,1:] = " Y"[outr]; // Guts are reformatted result // Print it out. 'SN#' - don't do nest boxes. 'S*' - print literals in // every row. '*' - loop format here. 'SC' - center values in column. // ':' - terminate after row is exhausted print("SN#, S*, V, ' | ', (*, SC, V, :, ' | ')", res); }