! form.txt - predicates involving expression form !/ (== % %) - identical expressions (in ) - x is member of the sequence (append1 ) - append one element to end of a sequence (concat .. ) - concatenate sequences (concat* ( .. ) ) - concat a sequence of sequences (instance ) - "var" instanced w arbitrary values (perm ) - two sequences are permutations of each other (=len ) - two sequences have equal length (seq=parts ) - partition sequence into parts of same length (3=parts <3parts>) - partition sequence into 3 equal-length parts (transpose ) - transpose a 2D array (distr ) - distribute seq of elems over seq of sequences (distr1 ) - distribute one elem over seq of sequences (end_distr ) - distr elems over ends of sequences (nulls ..()..) - list of arbitrary number of null sequences (cartesian .... ) - form cartesian product of sequences seq_1 - map sequence elements to 1-element sequences !\ ! == - identical expressions (== % %). ! in - membership in a sequence ! (or could call this "member") (in % (\$1 % \$2)). ! append1 - append one element to end of a sequence (append1 (\$) % (\$ %)). ! concat - concatenate a list of sequences ! (concat .. ) ! (This generalizes the concatenation of just two sequences.) (concat ()). ! concatenation of no sequences yields empty sequence (concat (\$seq) \$seqs (\$seq \$concat))< (concat \$seqs (\$concat)). ! concat* - concatenate a sequence of sequences ! (concat* ( .. ) ) (concat* (\$seqs) %concat)< (concat \$seqs %concat). ! instance - optionally replace "variable" occurrances in expr with arb expr ! ex: (instance _ (`a _ (0 _) _) (`a (`x) (0 5) _)) (instance %v % %). ! an expression can instance to itself (instance %v %v %). ! var can be replaced with any expression (instance %v (% \$) (%' \$'))< ! instancing elements of a sequence (instance %v % %'), (instance %v (\$) (\$')). ! perm - two sequences are permutations of each other (perm () ()). (perm (% \$) (\$1 % \$2))< (perm (\$) (\$1 \$2)). ! =len - two sequences have equal length (=len () ()). (=len (%1 \$1) (%2 \$2))< (=len (\$1) (\$2)). ! seq=parts - partition sequence into equal-length parts (seq=parts %seq %parts)< ! partition sequence into equal-length parts (concat* %parts %seq), ! parts concatenate to form sequence (binrel* =len %parts)). ! each part has same length ! 3=parts - partition sequence into 3 parts of equal length ! (This utility may be too Sudoku-specific!) (3=parts %seq (%1 %2 %3))< (seq=parts %seq (%1 %2 %3)). ! transpose - transpose a 2D array ! (transpose ) ! - Array is sequence of rows, each a sequence of same number of elements. ! (Note that if # rows = 0, # columns is indeterminant.) (transpose () (\$nulls))< ! no rows, so # columns is unknown (nulls \$nulls). ! (so transpose has any number of empty rows) (transpose (%row \$rows) %Tarr')< ! adding row to top of 2D array (transpose (\$rows) %Tarr), (distr %row %Tarr %Tarr'). ! distribute elems to front of Tarr rows ! -- Note that adding 1st row fixes number of columns. ! distr - distribute a seq of elements over (fronts of) sequences ! (distr ) (distr () () ()). (distr (% \$) ((\$seq) \$seqs) ((% \$seq) \$seqs'))< (distr (\$) (\$seqs) (\$seqs')). ! distr1 - distribute one (the same) element over (fronts of) sequences ! (distr1 ) (distr1 % () ()). (distr1 % ((\$seq) \$seqs) ((% \$seq) \$seqs'))< (distr1 % (\$seqs) (\$seqs')). ! end_distr - distribute a seq of elems over ends of sequences ! (end_distr ) (end_distr () () ()). (end_distr (\$seqs (\$seq)) (\$ %) (\$seqs' (\$seq %)))< (end_distr (\$seqs) (\$) (\$seqs')). ! nulls - list of null sequences (nulls). (nulls () \$nulls)< (nulls \$nulls). ! cartesian - form cartesian product tuples from elements of sequences ! (cartesian .... ) (cartesian (())). ! no sequence arguments yields single 0-elem "tuple" (cartesian () \$seqs ())< ! adding empty seq arg produces zero tuples (cartesian \$seqs %tuples). (cartesian (% \$) \$seqs (\$%tuples \$\$tuples))< ! add elem to 1st seq arg (cartesian \$seqs %tuples), ! tuples w/o 1st seq arg (distr1 % %tuples (\$%tuples)), ! form new tuples with % inserted (cartesian (\$) \$seqs (\$\$tuples)). ! tuples from the rest of 1st seq arg ! seq_1 - form 1-element sequences from sequence elements (seq_1 () ()). (seq_1 (% \$) ((%) \$'))< (seq_1 (\$) (\$')).