// SPDX-License-Identifier: LicenseRef-PD-hp OR CC0-1.0 OR 0BSD OR MIT-0 OR MIT // Generic utility functions // It is important for recursive functions to be tail recursive. This // minimizes the state that has to be retained while evaluating a // recursive function. // Check if a vector is just numbers for use in asserts. function is_num_v(vector,n=0) = n==len(vector)? true: is_num(vector[n])? is_num_v(vector,n+1): false ; // Sum up a vector. function sum(vector,n=0,sub=0) = n==len(vector)? sub: sum(vector,n+1,sub+vector[n]) ;