Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Pascal (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Set types=== In contrast with other programming languages from its time, Pascal supports a set type:<ref name="Mandell1987">{{cite book |first=Steven L. |last=Mandell |title=Pascal Programming Today |url=https://archive.org/details/turbopascalprogr00mand |url-access=registration |year=1987 |publisher=West Publishing Company |isbn=978-0-314-33935-5}}</ref> :<syntaxhighlight lang="pascal"> var Set1 : set of 1..10; Set2 : set of 'a'..'z'; </syntaxhighlight> A set is a fundamental concept for modern mathematics, and they may be used in many algorithms. Such a feature is useful and may be faster than an equivalent construct in a language that does not support sets. For example, for many Pascal compilers: :<syntaxhighlight lang="pascal"> if i in [5..10] then ... </syntaxhighlight> executes faster than: :<syntaxhighlight lang="pascal"> if (i > 4) and (i < 11) then ... </syntaxhighlight> Sets of non-contiguous values can be particularly useful, in terms of both performance and readability: :<syntaxhighlight lang="pascal"> if i in [0..3, 7, 9, 12..15] then ... </syntaxhighlight> For these examples, which involve sets over small domains, the improved performance is usually achieved by the compiler representing set variables as [[bit vector]]s. The set [[Operator (programming)|operators]] can then be implemented efficiently as bitwise machine code operations.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)