Related articles |
---|
[3 earlier articles] |
Re: Are Associative Arrays unique to Perl? leichter@smarts.com (Jerry Leichter) (1996-10-24) |
Re: Are Associative Arrays unique to Perl? ok@cs.rmit.edu.au (1996-10-24) |
Re: Are Associative Arrays unique to Perl? hbaker@netcom.com (1996-10-25) |
Re: Are Associative Arrays unique to Perl? phr@netcom.com (1996-10-30) |
Re: Are Associative Arrays unique to Perl? ian@five-d.com (1996-10-30) |
Re: Are Associative Arrays unique to Perl? lhf@csg.uwaterloo.ca (1996-10-30) |
Re: Are Associative Arrays unique to Perl? boffi@rachele.stru.polimi.it (giacomo boffi) (1996-10-30) |
Re: Are Associative Arrays unique to Perl? sitaram@diac.com (1996-11-03) |
Re: Are Associative Arrays unique to Perl? hbaker@netcom.com (1996-11-03) |
Re: Are Associative Arrays unique to Perl? hammen@gothamcity.jsc.nasa.gov (Dave Hammen) (1996-11-05) |
From: | giacomo boffi <boffi@rachele.stru.polimi.it> |
Newsgroups: | comp.lang.perl.misc,comp.lang.misc,comp.compilers |
Date: | 30 Oct 1996 13:27:47 -0500 |
Organization: | Universita' di Pisa |
References: | <5437ev$30u@shell1.aimnet.com> <545mqn$qul@picasso.op.net> 96-10-099 96-10-109 |
Keywords: | design, history |
here follows a long quote from the man page of "bs", "a remote
descendant of BASIC and SNOBOL4 with some C language added" (another
quote from bs(1)), that Hewlett-Packard ships with every copy of HP-UX
i make this post 'cause i'm curious about this "bs" thing, and i'd
like to know about its roots, uses, and most of all, why it is in the
HP-UX distribution!
ciao
gb
<-------------------------------------------------------------------->
Tables
table(name, size)
A table in bs is an associatively accessed,
single- dimension array. ``Subscripts'' (called
keys) are strings (numbers are converted). The
name argument must be a bs variable name (passed
as a string). The size argument sets the minimum
number of elements to be allocated. bs prints an
error message and stops on table overflow. The
result of table is name.
item(name, i)
key()
The item function accesses table elements
sequentially (in normal use, there is no orderly
progression of key values). Where the item
function accesses values, the key function
accesses the ``subscript'' of the previous item
call. It fails (or in the absence of an
interrogate operator, returns null) if there was
no valid subscript for the previous item call.
The name argument should not be quoted. Since
exact table sizes are not defined, the
interrogation operator should be used to detect
end-of-table; for example:
table("t", 100)
...
# If word contains "party", the following
# expression adds one to the count of that
# word:
++t[word]
...
# To print out the the key/value pairs:
for i = 0, ?(s = item(t, i)), ++i if key() put = key()_":"_s
If the interrogation operator is not used, the
result of item is null if there are no further
elements in the table. Null is, however, a legal
``subscript''.
iskey(name, word)
iskey tests whether the key word exists in the
table name and returns one for true, zero for
false.
[bs goes way back to the 5th or 6th edition of research Unix. Smells to me
like one of Ken Thompson's weekend hacks. -John]
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.