On 6/20/06, van Nek <van.nek at arcor.de> wrote:
>
> (%i2) block( [ibase:16], a );
> (%o2) a
> (%i3) block( ibase:16, a );
> (%o3) a
> (%i4) a;
> (%o4) 10
>
> An assignment to ibase in a block doesn't have any consequence inside the
> block itself.
> Does it make sense then, if this only works in top level?
>
The input lines have already been read by the time they are evaluated, so
ibase cannot have any effect on their reading. Here are examples of how you
could use a locally-bound ibase:
block([ibase:2],readonly("Binary number: "));
Binary number: 1010101010;
682
load("eval_string")$
block([ibase:2],eval_string("1011^111"));
19487171
inbase(str,base):=block([ibase:base],parse_string(str))$
inbase("100",16) => 256
Hope this helps.
-s