1827883 Members
1309 Online
109969 Solutions
New Discussion

Using arrays in DC

 
SOLVED
Go to solution
Jdamian
Respected Contributor

Using arrays in DC

Hi

I discovered that dc (desk calculator) can handle arrays. The only line about this in dc manual pages is:

; and : Used by bc for array operations.

I found some webpages where discuss how to specify the index in the array of a register but I cannot understand how array operations interacts with stack operations. In fact, some examples given in those other manual pages, result in core dump. For example, the manual pages of dc in cygwin:

Note that each stacked instance of a register has its own array associated with it. Thus 1 0:a 0Sa 2 0:a La 0;ap
will print 1, because the 2 was stored in an instance of 0:a that was later popped.

But this line makes dc crashes in HP-UX as well as Solaris.

5 REPLIES 5
Stephen Keane
Honored Contributor
Solution

Re: Using arrays in DC

$ echo "1 0:a 0Sa 2 0:a La 0;ap" | dc
1


Doesn't core dump on a B1000 HP-UX 11.11,
what version of dc are you using?

$ what /usr/bin/dc
/usr/bin/dc:
dc.c $Date: 2002/11/24 22:33:53 $Revision: r11.11/1 PATCH_11.11 (PHCO_27944)
$Revision: @(#) all CUP11.11_BL2003_0603_1 PATCH_11.11 PHCO_27944
Tue Jun 3 02:35:25 PDT 2003 $
Jdamian
Respected Contributor

Re: Using arrays in DC

# what /usr/bin/dc
/usr/bin/dc:
$Revision: B.11.11_LR
Fri Oct 27 00:30:16 PDT 2000 $


It's not patched.
Stephen Keane
Honored Contributor

Re: Using arrays in DC

I've tried looking up patch PHCO_27944
on the HP site, but it won't show me any details. I didn't specifically pacth ds, it must have been done as part of a general patch bundle.
Jdamian
Respected Contributor

Re: Using arrays in DC

I downloaded with no problem.

I-m going to install it as soon as possible.
Jdamian
Respected Contributor

Re: Using arrays in DC

problem solved