(use_fast_arrays:true,array(bil,3),0);
0$
bil[1];
false;
bil[1]:3;
3;
bil[1];
3;
listarray(bil);
[false, 3, false,false];
arrayinfo(bil);
[declared, 1, [3]];
ha[1]:2;
2;
ha[3];
false;
arrayinfo(ha);
[hash_table, 1, 1];
use_fast_arrays:false;
false;
array(bil1,3);
bil1;
bil1[2];
bil1[2];
bil1[2]:3;
3;
bil1[2];
3;
listarray(bil1);
[''?munbound,''?munbound,3,''?munbound];
arrayinfo(bil1);
[declared, 1, [3]];
oldha[1]:8;
8;
oldha[2];
oldha[2];
arrayinfo(oldha);
[hashed, 1, [1]];
use_fast_arrays:true;
true;
bilx[n]:=n*bilx[n-1];
bilx[n]:=n*bilx[n-1];
bilx[0]:1;
1;
bilx[3];
6;

use_fast_arrays: false;
false;

block ([use_fast_arrays : true], kill (foo), foo [2] : 'x, foo [3] : 'y, foo [5] : 'z, foo [7] : 'a, sort (listarray (foo)));
[a, x, y, z];

/* Bug #2978: "kill(a[i])" doesn't work with fast arrays */

block ([use_fast_arrays : true,
        y : yvalue],
  local (y),
  kill (foo),
  foo ['x] : 'x,
  foo ['y] : 'y,
  foo [ y] :  y,
  foo ['z] : 'z,
  /* Check that indices get evaluated */
  kill (foo ['y]),
  kill (foo [ y]),
  sort (listarray (foo)));
[x, z];

block ([use_fast_arrays : true,
        y : yvalue],
  local (y),
  kill (foo),
  foo [1, 'x] : 'x,
  foo [2, 'y] : 'y,
  foo [2,  y] :  y,
  foo [3, 'z] : 'z,
  /* Check that indices get evaluated */
  kill (foo [2, 'y]),
  kill (foo [2,  y]),
  sort (listarray (foo)));
[x, z];

/* kill(all) erases display properties for conjugate
 * mailing list 2017-02-24: "kill(all) results in non-default display options in wxMaxima"
 * Verify here that properties list for conjugate and friends is not reset by kill(all),
 * but it is reset by kill(foo) where foo = conjugate or friend.
 */

(?putprop ('conjugate, 111, 'foo),
 ?putprop (nounify ('erf_generalized), 222, 'bar),
 ?putprop ('beta, 333, 'baz),
 ?putprop ('nset, 444, 'quux),
 ?putprop ('maxmin, 666, 'blurf),
 ?putprop ('nummod, 777, 'barf),
 0);
0;

kill(all);
done;

[?get ('conjugate, 'foo),
 ?get (nounify ('erf_generalized), 'bar),
 ?get ('beta, 'baz),
 ?get ('nset, 'quux),
 ?get ('maxmin, 'blurf),
 ?get ('nummod, 'barf)];
[111, 222, 333, 444, 666, 777];

(kill (conjugate),
 apply (kill, [nounify ('erf_generalized)]),
 kill (beta),
 kill (nset, maxmin, nummod),
 0);
0;

[?get ('conjugate, 'foo),
 ?get (nounify ('erf_generalized), 'bar),
 ?get ('beta, 'baz),
 ?get ('nset, 'quux),
 ?get ('maxmin, 'blurf),
 ?get ('nummod, 'barf)];
[false, false, false, false, false, false];

/* verify that props is empty after kill(all) -- pre-bugfix behavior is that props
 * has several built-in symbols before and after kill(all)
 */

/* this test fails due to bug in kill(rules); see SF bug #3289 */
(kill(all), props);
[];

/* workaround bug #3289 */
(kill(all),
 not some (lambda ([x], member (x, props)),
           ['conjugate, nounify ('erf_generalized), 'beta, 'nset, 'maxmin, 'nummod]));
true;

(reset(use_fast_arrays),1);
1;

/* tests for at_difference */

kill (functions, values);
done;

(saved_display2d:display2d,
 display2d:true,
 0)$
0$

at_difference (sin(x), x, a, b);
sin(b) - sin(a);

'at_difference (sin(x), x, a, b);
'at_difference (sin(x), x, a, b);

block([display2d_unicode: false], printf (false, "~m", 'at_difference (sin(x), x, a, b)));
"      |x = b
sin(x)|
      |x = a
";

block([display2d_unicode: false], I: 'integrate (f(x), x, a, b) = 'at_difference ('integrate (f(x), x), x, a, b),
 printf (false, "~m", I));
" b                    |x = b
/            /        |
|            |        |
|  f(x) dx = | f(x) dx|
|            |        |
/            /        |
 a                    |x = a
";

I1: subst (f(x) = cos(h*x), I);
'integrate (cos(h*x), x, a, b) = 'at_difference ('integrate (cos(h*x), x), x, a, b);

block([display2d_unicode: false], printf (false, "~m", I1));
" b                            |x = b
/                /            |
|                |            |
|  cos(h x) dx = | cos(h x) dx|
|                |            |
/                /            |
 a                            |x = a
";

I1a: ev (I1, at_difference);
'integrate (cos(h*x), x, a, b) = 'at ('integrate (cos(h*x), x), x = b) - 'at ('integrate (cos(h*x), x), x = a);

I1b: ev (I1a, integrate);
sin(h*b)/h - sin(h*a)/h = 'at (sin(h*x)/h, x = b) - 'at (sin(h*x)/h, x = a);

I1c: ev (I1b, at);
sin(h*b)/h - sin(h*a)/h = sin(h*b)/h - sin(h*a)/h;

is (I1c);
true;

I1d: ev (I1, integrate);
sin(h*b)/h - sin(h*a)/h = 'at_difference (sin(h*x)/h, x, a, b);

I1e: ev (I1d, at_difference);
sin(h*b)/h - sin(h*a)/h = sin(h*b)/h - sin(h*a)/h;

is (I1e);
true;

I1f: ev (I1, nouns);
sin(h*b)/h - sin(h*a)/h = sin(h*b)/h - sin(h*a)/h;

is (I1f);
true;

block([display2d_unicode: false], aa: abs (box ('at_difference ((1 - g(u[k]))/(1 + g(u[k])), u[k], 2/3, 5/7))),
 printf (false, "~m", aa));
"|\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"|
|\"               5\"|
|\"         |u  = -\"|
|\"1 - g(u )| k   7\"|
|\"       k |      \"|
|\"---------|      \"|
|\"g(u ) + 1|      \"|
|\"   k     |     2\"|
|\"         |u  = -\"|
|\"           k   3\"|
|\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"|
";

ev (aa, at_difference);
/* ensure following result is simplified so that MMINUS and MQUOTIENT are replaced by simplified expressions */
''(abs (box ((1 - g(5/7))/(g(5/7) + 1) - (1 - g(2/3))/(g(2/3) + 1))));

(display2d:saved_display2d, 0)$
0$
