/* Demo 29 March 2005 */
public class Demo {
    
    /** == arrays b and c are equal (it they are both null, they are equal) */
    public static boolean equals(int[] b, int[] c) {
        if (b==null && c==null)
            return true;
        if (b== null || c==null)
            return false;
        if (b.length != c.length)
            return false;
        // b and c have the same length
        
        // invariant b[0..k-1] = c[0..k-1]
        for (int k= 0; k != b.length; k= k+1) {
            if (b[k] != c[k])
                return false;
        }
        
        
        // b[0..b.length-1] = c[0..b.length-1]
        return true;
    }
    
    
    /** = a copy of b */
    public static int[] copy(int[] b) {
        if (b==null)
            return null;
        int[] ans= new int[b.length];
        
        // invariant: ans[0..k-1] = b[0..k-1]
        for (int k= 0; k != b.length; k= k+1) {
            ans[k]= b[k];
        }
        
        
        // ans[0..b.length-1] = b[0..b.length-1]
        return ans;
    }
    
    // = string rep of b --in the form "{b1, b2, ..., bn}"
    public static String toString(int[] b) {
        String res= "{";
        
        // inv:res contains rep of b[0..k-1] without }
        for (int k= 0; k != b.length; k= k+1) {
            if (k != 0) {
                res= res + ", ";
            }
            res= res + b[k];
        }
        
        // res contains rep of b[0..b.length-1] without }
        return res + "}";
    }
    
    
    
}