Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!strath-cs!cs.glasgow.ac.uk!jack From: jack@cs.glasgow.ac.uk (Jack Campin) Newsgroups: comp.lang.misc Subject: testing whether a key is present in an ABC table Message-ID: <5989@vanuata.cs.glasgow.ac.uk> Date: 8 Aug 90 14:34:42 GMT Organization: Computing Sci, Glasgow Univ, Scotland Lines: 24 I've just been reading Geurts, Meertens and Pemberton's "ABC Programmer's Handbook" (Prentice-Hall, ISBN 0-13-000027-2). ABC has a useful type constructor called the "table", which allows associative access to values of any type based on keys of any type. There seems to be one rather important facility missing: a way to test if a key is present in a table. There IS a direct way to test if a pair is present, but the only way the book describes to test for a key alone is by first constructing a sorted list of the keys (using a standard function "keys") and then testing the key's presence in the list. They don't describe the way "keys" works, but nothing suggests that it's lazy. If it isn't, this is unacceptably inefficient for an application that performs a long series of query-and-update transactions on a large persistent table. Workarounds? Do I have to run "keys" at the start of the application and then maintain an update log? Not very elegant. -- -- Jack Campin Computing Science Department, Glasgow University, 17 Lilybank Gardens, Glasgow G12 8QQ, Scotland 041 339 8855 x6044 work 041 556 1878 home JANET: jack@cs.glasgow.ac.uk BANG!net: via mcsun and ukc FAX: 041 330 4913 INTERNET: via nsfnet-relay.ac.uk BITNET: via UKACRL UUCP: jack@glasgow.uucp