Recent from talks
Nothing was collected or created yet.
Vertical bar
View on Wikipedia| | | |
|---|---|
Vertical bar | |
| In Unicode | U+007C | VERTICAL LINE (|, |, |) |
| Related | |
| See also | U+00A6 ¦ BROKEN BAR (¦) U+2016 ‖ DOUBLE VERTICAL LINE (‖, ‖) |
The vertical bar, |, is a glyph with various uses in mathematics, computing, and typography. It has many names, often related to particular meanings: Sheffer stroke (in logic), pipe, bar, or (literally, the word "or"), vbar, and others.[1]
Usage
[edit]Mathematics
[edit]The vertical bar is used as a mathematical symbol in numerous ways. If used as a pair of brackets, it suggests the notion of the word "size". These are:
- absolute value: , read "the absolute value of x"[2]
- cardinality: , read "the cardinality of the set S" or "the length of a string S"
- determinant: , read "the determinant of the matrix A".[2] When the matrix entries are written out, the determinant is denoted by surrounding the matrix entries by vertical bars instead of the usual brackets or parentheses of the matrix, as in .
- order: , read "the order of the group G", or , "the order of the element "
Likewise, the vertical bar is also used singly in many different ways:
- conditional probability: , read "the probability of X given Y"
- distance: , denoting the shortest distance between point to line , so line is perpendicular to line
- divisibility: , read "a divides b" or "a is a factor of b", though Unicode also provides special 'divides' and 'does not divide' symbols (U+2223 ∣ DIVIDES and U+2224 ∤ DOES NOT DIVIDE)[2]
- function evaluation: , read "f of x, evaluated at x equals 4" (see subscripts at Wikibooks)
- restriction: , denoting the restriction of the function , with a domain that is a superset of , to just
- set-builder notation: , read "the set of x such that x is less than two". Often, a colon ':' is used instead of a vertical bar
- the Sheffer stroke in logic: , read "a nand b"
- subtraction: , read "f(x) from a to b", denoting . Used in the context of a definite integral with variable x.
- A vertical bar can be used to separate variables from fixed parameters in a function, for example , or in the notation for elliptic integrals.
The double vertical bar, , is also employed in mathematics.
- parallelism: , read "the line is parallel to the line "
- norm: , read "the norm (length, size, magnitude etc.) of the matrix ". The norm of a one-dimensional vector is the absolute value and single bars are used.[3]
- Propositional truncation: (a type former that truncates a type down to a mere proposition in homotopy type theory): for any (read "term of type ") we have [4] (here reads "image of in " and reads "propositional truncation of ")[5]
In LaTeX mathematical mode, the ASCII vertical bar produces a vertical line, and \| creates a double vertical line (a | b \| c is set as ). This has different spacing from \mid and \parallel, which are relational operators: a \mid b \parallel c is set as . See below about LaTeX in text mode.
Chemistry
[edit]In chemistry, the vertical line is used in cell notation of electrochemical cells.
Example,
Zn | Zn2+ || Cu2+ | Cu
Single vertical lines show components of the cell which do not mix, usually being in different phases. The double vertical line ( || ) is used to represent salt bridge; which is used to allow free moving ions to move.
Physics
[edit]The vertical bar is used in bra–ket notation in quantum physics. Examples:
- : the quantum physical state
- : the dual state corresponding to the state above
- : the inner product of states and
- Supergroups in physics are denoted G(N|M), which reads "G, M vertical bar N"; here G denotes any supergroup, M denotes the bosonic dimensions, and N denotes the Grassmann dimensions.[6]
Computing
[edit]Pipe
[edit]A pipe is an inter-process communication mechanism originating in Unix, which directs the output (standard out and, optionally, standard error) of one process to the input (standard in) of another. In this way, a series of commands can be "piped" together, giving users the ability to quickly perform complex multi-stage processing from the command line or as part of a Unix shell script ("bash file"). In most Unix shells (command interpreters), this is represented by the vertical bar character. For example:
grep -i 'blair' filename.log | more
where the output from the grep process (all lines containing 'blair') is piped to the more process (which allows a command line user to read through results one page at a time).
The same "pipe" feature has been borrowed for use in other operating systems.
This usage has led to the character itself being called "pipe".
Disjunction
[edit]In many programming languages, the vertical bar is used to designate the logic operation or, either bitwise or or logical or.
Specifically, in C and other languages following C syntax conventions, such as C++, Perl, Java and C#, a | b denotes a bitwise or; whereas a double vertical bar a || b denotes a (short-circuited) logical or. Since the character was originally not available in all code pages and keyboard layouts, ANSI C can transcribe it in form of the trigraph ??!, which, outside string literals, is equivalent to the | character.
In regular expression syntax, the vertical bar again indicates logical or (alternation). For example: the Unix command grep -E 'fu|bar' matches lines containing 'fu' or 'bar'.
Concatenation
[edit]The double vertical bar operator "||" denotes string concatenation in PL/I, REXX, ooRexx, standard ANSI SQL, and theoretical computer science (particularly cryptography).
Delimiter
[edit]Although not as common as commas or tabs, the vertical bar can be used as a delimiter in a flat file. Examples of a pipe-delimited standard data format are LEDES 1998B and HL7. It is frequently used because vertical bars are typically uncommon in the data itself.
Similarly, the vertical bar may see use as a delimiter for regular expression operations (e.g. in sed). This is useful when the regular expression contains instances of the more common forward slash (/) delimiter; using a vertical bar eliminates the need to escape all instances of the forward slash. However, this makes the bar unusable as the regular expression "alternative" operator.
Backus–Naur form
[edit]In Backus–Naur form, an expression consists of sequences of symbols and/or sequences separated by '|', indicating a choice, the whole being a possible substitution for the symbol on the left.
<personal-name> ::= <name> | <initial>
Concurrency operator
[edit]In calculi of communicating processes (like pi-calculus), the vertical bar is used to indicate that processes execute in parallel.
APL
[edit]The pipe in APL is the modulo or residue function between two operands and the absolute value function next to one operand.
List comprehensions
[edit]The vertical bar is used for list comprehensions in some functional languages, e.g. Haskell and Erlang. Compare set-builder notation.
Text markup
[edit]The vertical bar is used as a special character in lightweight markup languages, notably MediaWiki's Wikitext (in the templates and internal links).
In LaTeX text mode, the vertical bar produces an em dash (—). The \textbar command can be used to produce a vertical bar.
Phonetics and orthography
[edit]In the Khoisan languages and the International Phonetic Alphabet, the vertical bar is used to write the dental click (ǀ). A double vertical bar is used to write the alveolar lateral click (ǁ). Since these are technically letters, they have their own Unicode code points in the Latin Extended-B range: U+01C0 ǀ LATIN LETTER DENTAL CLICK and U+01C1 ǁ LATIN LETTER LATERAL CLICK.
Some Northwest and Northeast Caucasian languages written in the Cyrillic script have a vertical bar called palochka (Russian: палочка, lit. 'little stick'), indicating the preceding consonant is an ejective.
Longer single and double vertical bars are used to mark prosodic boundaries in the IPA.
Literature
[edit]
In medieval European manuscripts, a single vertical bar was a common variant of the virgula / used as a comma,[7] or caesura mark.[7]
In Sanskrit and other Indian languages, a single vertical mark, ।, called a danda, has a similar function as a period (full stop). Two bars, ॥, (a 'double danda') is the equivalent of a pilcrow in marking the end of a stanza, paragraph or section. The danda has its own Unicode code point, U+0964 । DEVANAGARI DANDA; as does the double danda: U+0965 ॥ DEVANAGARI DOUBLE DANDA.
Poetry
[edit]A double vertical bar ⟨||⟩ or ⟨‖⟩[citation needed] is the standard caesura mark in English literary criticism and analysis. It marks the strong break or caesura common to many forms of poetry, particularly Old English verse. It is also traditionally used to mark the division between lines of verse printed as prose (the style preferred by Oxford University Press), though it is now often replaced by the forward slash.[citation needed]
Notation
[edit]In the Geneva Bible and early printings of the King James Version, a double vertical bar is used to mark margin notes that contain an alternative translation from the original text. These margin notes always begin with the conjunction "Or". In later printings of the King James Version, the double vertical bar is irregularly used to mark any comment in the margins.
A double vertical bar symbol may be used to call out a footnote. (The traditional order of these symbols in English is *, †, ‡, §, ‖, ¶, so its use is very rare; in modern usage, numbers and letters are preferred for endnotes and footnotes.[8])
Music scoring
[edit]In music, when writing chord sheets, single vertical bars associated with a colon (|: A / / / :|) represents the beginning and end of a section (e.g. Intro, Interlude, Verse, Chorus) of music.[citation needed] Single bars can also represent the beginning and end of measures (|: A / / / | D / / / | E / / / :|). A double vertical bar associated with a colon can represent the repeat of a given section (||: A / / / :|| - play twice).[citation needed]
Broken bar
[edit]
Many early video terminals and dot-matrix printers rendered the vertical bar character as the allograph broken bar ¦. This may have been to distinguish the character from the lower-case 'L' and the upper-case 'I' on these limited-resolution devices, and to make a vertical line of them look more like a horizontal line of dashes. It was also (briefly) part of the ASCII standard.
An initial draft for a 7-bit character set that was published by the X3.2 subcommittee for Coded Character Sets and Data Format on June 8, 1961, was the first to include the vertical bar in a standard set. The bar was intended to be used as the representation for the logical OR symbol.[9] A subsequent draft on May 12, 1966, places the vertical bar in column 7 alongside regional entry codepoints, and formed the basis for the original draft proposal used by the International Standards Organisation.[9] This draft received opposition from the IBM user group SHARE, with its chairman, H. W. Nelson, writing a letter to the American Standards Association titled "The Proposed revised American Standard Code for Information Interchange does NOT meet the needs of computer programmers!"; in this letter, he argues that no characters within the international subset designated at columns 2-5 of the character set would be able to adequately represent logical OR and logical NOT in languages such as IBM's PL/I universally on all platforms.[10] As a compromise, a requirement was introduced where the exclamation mark (!) and circumflex (^) would display as logical OR (|) and logical NOT (¬) respectively in use cases such as programming, while outside of these use cases they would represent their original typographic symbols:
"It may be desirable to employ distinctive styling to facilitate their use for specific purposes as, for example, to stylize the graphics in code positions 2/1 and 5/14 to those frequently associated with logical OR (|) and logical NOT (¬) respectively."
— X3.2 document X3.2/475[11]
The original vertical bar encoded at 0x7C in the original May 12, 1966 draft was then broken as ¦, so it could not be confused with the unbroken logical OR. In the 1967 revision of ASCII, along with the equivalent ISO 464 code published the same year, the code point was defined to be a broken vertical bar, and the exclamation mark character was allowed to be rendered as a solid vertical bar.[12][13] However, the 1977 revision (ANSI X.3-1977) undid the changes made in the 1967 revision, enforcing that the circumflex could no longer be stylised as a logical NOT symbol, the exclamation mark likewise no longer allowing stylisation as a vertical bar, and defining the code point originally set to the broken bar as a solid vertical bar instead;[12] the same changes were also reverted in ISO 646-1973 published four years prior.
Some variants of EBCDIC included both versions of the character as different code points. The broad implementation of the extended ASCII ISO/IEC 8859 series in the 1990s also made a distinction between the two forms. This was preserved in Unicode as a separate character at U+00A6 ¦ BROKEN BAR (the term "parted rule" is used sometimes in Unicode documentation). Some fonts draw the characters the same (both are solid vertical bars, or both are broken vertical bars).[14][failed verification]
The broken bar does not appear to have any clearly identified uses distinct from those of the vertical bar.[15] In non-computing use — for example in mathematics, physics and general typography — the broken bar is not an acceptable substitute for the vertical bar. In some dictionaries, the broken bar is used to mark stress that may be either primary or secondary: [¦ba] covers the pronunciations [ˈba] and [ˌba].[16]
Unicode
[edit]- U+007C | VERTICAL LINE (|, |, |) (single vertical line)
- U+00A6 ¦ BROKEN BAR (¦) (single broken line)
- U+2016 ‖ DOUBLE VERTICAL LINE (‖, ‖) (double vertical line ( ): used in pairs to indicate norm)
- U+FF5C | FULLWIDTH VERTICAL LINE (Fullwidth form)
- U+FFE4 ¦ FULLWIDTH BROKEN BAR
- U+2225 ∥ PARALLEL TO (∥, ∥, ∥, ∥, ∥)
- U+01C0 ǀ LATIN LETTER DENTAL CLICK
- U+01C1 ǁ LATIN LETTER LATERAL CLICK
- U+2223 ∣ DIVIDES (∣, ∣, ∣, ∣)
- U+2502 │ BOX DRAWINGS LIGHT VERTICAL (│) (and various other box drawing characters in the range U+2500 to U+257F)
- U+2758 ❘ LIGHT VERTICAL BAR
- U+0964 । DEVANAGARI DANDA
- U+0965 ॥ DEVANAGARI DOUBLE DANDA
Historical encodings
[edit]| Code pages, ASCII, ISO/IEC, EBCDIC, Shift-JIS, etc. | Vertical bar (|)
|
Broken bar (¦)
|
|---|---|---|
| ASCII, CP437, CP667, CP720, CP737, CP790, CP819, CP852, CP855, CP860, CP861, CP862, CP865, CP866, CP867, CP869, CP872, CP895, CP932, CP991 |
124 (7Ch) | none |
| CP775 | 167 (A7h) | |
| CP850, CP857, CP858 | 221 (DDh) | |
| CP863 | 160 (A0h) | |
| CP864 | 219 (DBh) | |
| ISO/IEC 8859-1, -7, -8, -9, -13, CP1250, CP1251, CP1252, CP1253, CP1254, CP1255, CP1256, CP1257, CP1258 |
166 (A6h) | |
| ISO/IEC 8859-2, -3, -4, -5, -6, -10, -11, -14, -15, -16 | none | |
| EBCDIC CCSID 37 | 79 (4Fh) | 106 (6Ah) |
| EBCDIC CCSID 500 | 187 (BBh) | |
| JIS X 0208, JIS X 0213 | Men-ku-ten 1-01-35 (7-bit: 2143h; Shift JIS: 8162h; EUC: A1C3h)[a] | none |
See also
[edit]- Bar (diacritic) – Diacritic used in some languages
- Triple bar – Symbol with multiple meanings
Notes
[edit]- ^ The Shift JIS and EUC encoded forms also include the ASCII vertical bar in its usual encoding (see halfwidth and fullwidth forms). The same applies when the 7-bit form is used as part of ISO-2022-JP (allowing switching to and from ASCII).
References
[edit]- ^ Raymond, Eric S. "ASCII". The Jargon File. Archived from the original on Oct 30, 2023.
- ^ a b c Weisstein, Eric W. "Single Bar". Wolfram MathWorld. Retrieved 2020-08-24.
- ^ Weisstein, Eric W. "Matrix Norm". Wolfram MathWorld. Retrieved 2020-08-24.
- ^ Univalent Foundations Program (2013). Homotopy Type Theory: Univalent Foundations of Mathematics (GitHub version) (PDF). Institute for Advanced Study. p. 108. Archived from the original (PDF) on 2017-07-07. Retrieved 2017-07-01.
- ^ Univalent Foundations Program (2013). Homotopy Type Theory: Univalent Foundations of Mathematics (print version). Institute for Advanced Study. p. 450.
- ^ Larus Thorlacius, Thordur Jonsson (eds.), M-Theory and Quantum Geometry, Springer, 2012, p. 263.
- ^ a b "Virgule". Oxford English Dictionary. Vol. XII (Corrected reissue ed.). Oxford University Press. 1933. p. 235..
- ^ Bringhurst, Robert (2005). The Elements of Typographic Style (ver. 3.1 ed.). Point Roberts, Washington: Hartley and Marks. pp. 68–69.
But beyond the ... double dagger, this order is not familiar to most readers, and never was.
- ^ a b Fischer, Eric (2012). The Evolution of Character Codes, 1874-1968 (Thesis). Penn State University. CiteSeerX 10.1.1.96.678. Retrieved July 10, 2020.
- ^ H. W. Nelson, letter to Thomas B. Steel, June 8, 1966, Honeywell Inc. X3.2 Standards Subcommittee Records, 1961-1969 (CBI 67), Charles Babbage Institute, University of Minnesota, Minneapolis, box 1, folder 23.
- ^ X3.2 document X3.2/475, December 13, 1966, Honeywell Inc. X3.2 Standards Subcommittee Records, 1961-1969 (CBI 67), Charles Babbage Institute, University of Minnesota, Minneapolis, box 1, folder 22.
- ^ a b Salste, Tuomas (January 2016). "7-bit character sets: Revisions of ASCII". Aivosto Oy. urn:nbn:fi-fe201201011004. Archived from the original on 2016-06-13. Retrieved 2016-06-13.
- ^ Korpela, Jukka. "Character histories - notes on some Ascii code positions". Archived from the original on 2020-03-11. Retrieved 2020-05-31.
- ^ Jim Price (2010-05-24). "ASCII Chart: IBM PC Extended ASCII Display Characters". Retrieved 2012-02-23.
- ^ Jukka "Yucca" Korpela (2006-09-20). "Detailed descriptions of the characters". Retrieved 2012-02-23.
- ^ For example, "Balearic". Merriam-Webster.com Dictionary. Merriam-Webster..
Vertical bar
View on Grokipediacat file.txt | wc counts the words in a file by piping its contents.[3] It also acts as a bitwise OR operator in languages like C/C++, performing binary operations on integers, and as part of the logical OR (||) for conditional statements.[4] In regular expressions, a single | signifies alternation, matching one pattern or another, such as a|b for "a or b."[3] Typographically, it appears as a separator in URLs, tables, or menus to divide elements clearly.[9]
Mathematical and scientific notation
Mathematics
In number theory, the vertical bar denotes divisibility, where means that divides if there exists an integer such that .[10] This notation indicates that is an integer multiple of , without implying division in the arithmetic sense. For example, holds because , whereas since no such integer exists. The symbol was introduced in unpublished notes from G. H. Hardy's 1925 number theory seminar and first appeared in print in Edmund Landau's 1927 book Elementary Number Theory.[11] In probability theory, the vertical bar represents conditional probability, denoted as , which is the probability that event occurs given that event has occurred, assuming . This is defined as , where is the joint probability of both events.[12] The formula derives from the axioms of probability in measure-theoretic terms, treating events as subsets of a sample space; specifically, it normalizes the measure of the intersection by the measure of , reflecting the restriction of the probability space to outcomes in . This notation, using the vertical bar for "given," became standardized in the mid-20th century following earlier variants like Kolmogorov's in 1933.[13] The vertical bars also denote the absolute value of a real number , written as , which gives the distance of from zero on the number line and is always non-negative. For , ; for , . This single-bar notation, adopted widely in the 20th century, replaced earlier uses of double bars for magnitude in some contexts, particularly as linear algebra distinguished norms with double bars. The shift emphasized clarity in elementary contexts, as documented in historical surveys of mathematical symbols. In linear algebra, vertical bars enclose a square matrix to denote its determinant, so for an matrix . The determinant measures properties like invertibility and volume scaling under linear transformations. For a 2×2 matrix , the determinant is computed as . For instance, if , then . This notation traces to Arthur Cayley's 1841 work, where double vertical lines were used, evolving to single bars as the standard by the late 19th century.[14][15]Chemistry
In chemistry, the vertical bar (|) serves as a delimiter in several notations, particularly in electrochemistry and phase representations, to indicate boundaries between different phases or components. A primary application is in the cell notation for electrochemical cells, where a single vertical bar denotes a phase boundary, such as between a solid electrode and its surrounding electrolyte solution. For instance, in the Daniell cell, the notation Zn | Zn²⁺ || Cu²⁺ | Cu represents the zinc anode in contact with zinc ions (separated by |), the salt bridge (||), and the copper cathode with copper ions (separated by |). This convention allows concise depiction of the cell's structure without drawing diagrams, with components listed from left to right across the cell.[16] The double vertical bar (||) specifically indicates the salt bridge or a liquid junction with low resistance, distinguishing it from single bars for phase interfaces.[17] The vertical bar also represents phase boundaries in broader chemical contexts, such as solubility equilibria or multi-phase systems. According to IUPAC recommendations, a single | separates immiscible phases, like in the notation for a gas-liquid interface (e.g., H₂(g) | H₂O(l)), while a dashed vertical bar (│) denotes junctions between miscible liquids, and || indicates immiscible liquid boundaries. This usage extends to phase diagrams, where vertical lines mark transitions, such as the solid | liquid boundary in a one-component diagram, helping to visualize regions of stability for each phase under varying temperature and pressure.[17] The vertical bar has a limited role in SMILES (Simplified Molecular Input Line Entry System) notation for organic structures, primarily in extensions for annotations or stereochemistry. For example, in some parsers like RDKit, | delimits non-standard features such as lone pair specifications (e.g., O|lp for oxygen with a lone pair tag), though core SMILES uses / and \ for double-bond configurations like in trans-but-2-ene (C/C=C/C). This usage supports advanced molecular modeling but is not part of the basic Daylight SMILES specification.[18]Physics
In physics, the vertical bar denotes the magnitude of physical quantities, particularly vectors, distinguishing it from the vector's directional properties. For a velocity vector v, the speed is represented as |v|, yielding a scalar value that quantifies the object's motion without direction. This usage emphasizes the non-negative length of the vector in Euclidean space, as seen in kinematic equations where |r| gives displacement magnitude. Unlike abstract scalar norms in higher mathematics, the single vertical bars in physics conventionally apply the Euclidean norm for three-dimensional vectors, ensuring compatibility with empirical measurements.[19] A prominent application occurs in quantum mechanics through Dirac notation, where vertical bars define kets and contribute to bras. A quantum state is expressed as a ket |φ⟩, a column vector in Hilbert space, while its dual bra is ⟨ψ|, a row vector formed by the Hermitian conjugate. The inner product between states, ⟨ψ|φ⟩, computes the overlap integral, yielding a complex number whose magnitude squared gives the transition probability: This notation simplifies operator applications and expectation values, such as ⟨ψ|Ĥ|ψ⟩ for energy. Paul Dirac introduced this bra-ket formalism in 1939 to streamline quantum expressions, replacing cumbersome wave function integrals with abstract vector operations while preserving physical interpretability.[20]Computing and programming
Pipe operator
In Unix-like operating systems, the vertical bar serves as the pipe operator |, which redirects the standard output of a command on its left as the standard input to a command on its right, enabling the chaining of multiple processes in a data stream. This mechanism, known as shell piping, was conceived by Douglas McIlroy and implemented in the third edition of Unix in 1973 by Ken Thompson, following McIlroy's advocacy for linking programs to process streams efficiently.[21][22] For example, the commandls | grep "file" lists directory contents and filters for lines containing "file", demonstrating how output flows seamlessly without manual file handling.
Piping supports chaining of multiple commands, as seen in Bash with expressions like cat file.txt | sort | uniq, where the contents of a file are read, sorted alphabetically, and deduplicated in a single pipeline. PowerShell adopts a similar | operator for object-oriented pipelines, allowing cmdlets to process .NET objects directly; for instance, Get-Process | Where-Object {$_.CPU -gt 100} | Stop-Process retrieves processes, filters those using over 100 CPU units, and terminates them.[23] This streaming approach enhances performance by avoiding the creation of intermediate files, reducing disk I/O overhead compared to temporary file-based workflows, though kernel-level buffering in pipes can introduce latency for very large datasets.[24]
Beyond shells, the pipe concept extends to programming languages for function composition. In Elixir, the |> operator chains functions by passing the result of the left expression as the first argument to the right, as in String.split("hello world", " ") |> Enum.map(&String.capitalize/1), which splits a string and capitalizes each word.[25] Similarly, R's magrittr package provides the %>% operator for forwarding values through a sequence of functions, exemplified by mtcars %>% subset(cyl == 6) %>% transform(mpg = mpg * 1.1), which filters a dataset and modifies values in a readable pipeline.[26]
Logical disjunction
The vertical bar | is used as a symbol for logical disjunction in some notations, particularly in computing and programming languages, representing the inclusive OR operation where the compound proposition P | Q is true if at least one of P or Q is true, and false only if both are false.[27] This operation is fundamental to Boolean algebra and formal reasoning systems. The truth table for the disjunction of two propositions P and Q using | is as follows: | P | Q | P | Q | |-------|-------|-------| | True | True | True | | True | False | True | | False | True | True | | False | False | False | This table illustrates the inclusive nature of the operation, where the result is true in three out of four cases.[28] In programming languages, the vertical bar | is employed as a logical OR operator in certain contexts, notably in ALGOL 68, where it evaluates to true if either operand is true, as defined in the language's standard prelude for boolean expressions.[29] For example, in ALGOL 68, an expression likep | q combines two boolean values, yielding true if at least one is true.[29] This usage was introduced in the design of ALGOL 68, ratified in 1968, influencing subsequent languages' adoption of vertical bar variants for disjunctive logic.[30]
In contrast, many C-like programming languages, such as C and Java, distinguish between the single vertical bar | as a bitwise OR operator—which performs bit-by-bit disjunction on integer operands—and the double vertical bar || as the logical OR operator, which evaluates boolean conditions and supports short-circuit evaluation.[31] For instance, in C, if (a | b) applies bitwise OR to the values of a and b before the conditional check, potentially evaluating both even if the first is nonzero, whereas if (a || b) uses logical OR and skips the second operand if the first is true.[32] This distinction ensures bitwise operations handle numerical data efficiently while logical operations prioritize boolean semantics and performance in control flow.[31]
String concatenation
In several programming languages and database query standards, the vertical bar serves as part of the double vertical bar operator (||), which is dedicated to string concatenation, joining two or more strings or compatible expressions into a single string by appending them sequentially.[33] This operator originated in early systems programming languages and has been standardized for clarity and type safety. One of the earliest uses appears in PL/I, a general-purpose language developed in the 1960s by IBM for mainframe computing, where || explicitly concatenates character, bit, or graphic strings, potentially triggering implicit conversions to string types if operands are not already strings.[33] For example, the expressionNAME = FIRSTNAME || ' ' || LASTNAME; produces a full name string by combining variables and a literal space.[33] Similarly, in REXX, a scripting language introduced by IBM in 1979 for system automation, || performs string concatenation on terms such as variables, literals, or expressions, with no implicit type conversion required as all values are treated as strings by default.[34]
The || operator is also the ANSI SQL standard for string concatenation across database systems like PostgreSQL, Oracle, and Vertica, allowing the merging of column values, literals, and constants.[35] For instance, SELECT first_name || ' ' || last_name AS full_name FROM employees; retrieves employee records with names joined by a space, handling NULL values by propagating them to produce a NULL result if any operand is NULL.[35] This usage extends to other dialects, such as SQLite, where || replaces the non-standard + in some contexts for portability.
A key advantage of || over the + operator—commonly used for arithmetic addition—is its explicit focus on strings, which mitigates type coercion issues where mixing numeric and string operands could lead to unintended addition instead of concatenation.[36] For example, in languages overloading + (like JavaScript or early BASIC dialects), "1" + 2 might yield the string "12", but 1 + "2" could coerce to numeric addition resulting in 3, causing bugs in dynamic contexts; || enforces string handling without such ambiguity.[36] This design choice promotes safer code in mixed-type expressions, as seen in PL/I and SQL where + remains reserved for numerics.[33]
Delimiters and separators
In file URI schemes for Windows and DOS-derived systems, the vertical bar replaces the colon in drive letter specifications to comply with URI syntax rules, where the colon is reserved. For instance, the local pathC:\Users\file.txt is represented as file:///C|/Users/file.txt.[37]
Certain APIs, especially those adhering to the OpenAPI Specification, support the pipeDelimited serialization style for query parameters, using the vertical bar to separate array or object values within a single parameter. An example is ?color=blue|black|brown, which specifies multiple color options.[38]
As an alternative to comma-separated values (CSV) files, pipe-delimited files—often called pipe-separated values (PSV)—use the vertical bar to separate fields, avoiding issues with comma-containing data. A typical record might appear as name|age|city, such as John Doe|30|New York. Government agencies like the U.S. Census Bureau employ this format for datasets, including geographic gazetteer files.[39]
In regular expressions, the vertical bar functions as an alternation operator, enabling a pattern to match one of multiple specified alternatives. For example, cat|dog matches either "cat" or "dog" in a string. To treat the vertical bar as a literal character rather than an operator, it requires escaping, commonly as \| in most regex engines.[40]
Formal grammars
In formal grammars, the vertical bar serves as a key symbol for denoting alternatives within production rules, enabling concise descriptions of syntactic choices in context-free grammars. This usage originated with John Backus's notation for the ALGOL 58 report in 1959, where it separated possible expansions of non-terminals to precisely define the language's syntax.[41] The notation was later refined and named Backus-Naur Form (BNF) by Peter Naur in the ALGOL 60 report, establishing it as a standard for specifying programming language grammars.[42] In BNF, a production rule uses the vertical bar (|) to list mutually exclusive options following the double colon (::=) symbol. For instance, the syntax for a single digit can be expressed as<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9, indicating that any one of these terminal symbols satisfies the non-terminal <digit>.[43] This structure allows recursive definitions for complex constructs, such as arithmetic expressions: <expression> ::= <term> | <expression> + <term> | <expression> - <term>. Such rules underpin the grammars of many programming languages, including Python, where the official grammar employs | to specify alternatives like statement ::= compound_stmt | simple_stmts.[44]
Extended Backus-Naur Form (EBNF) builds on BNF by retaining the vertical bar for alternatives while introducing additional operators, such as square brackets [] for optional elements and curly braces {} or asterisks * for repetition. For example, an EBNF rule for a comma-separated list might be <list> ::= <item> ("," <item>)*, with | used if multiple base forms for <item> are needed, like <item> ::= <number> | <string>. This extension enhances expressiveness without altering the core role of | in marking choices, and it appears in specifications for protocols and data formats.[43]
Graphical representations of grammars, known as syntax or railroad diagrams, visualize alternatives through branching paths connected by vertical lines at choice points. These lines indicate where the parser selects one of several possible routes, mirroring the logical separation provided by | in textual BNF. For example, in a diagram for a conditional statement, vertical lines might fork to paths representing "if-then" or "if-then-else" structures.[45] This visual aid complements textual notations, aiding comprehension of grammar rules in language definitions.
Concurrency and parallelism
In process calculi, the vertical bar symbolizes parallel composition, enabling the concurrent execution of independent processes. In the Calculus of Communicating Systems (CCS), introduced by Robin Milner, the notation represents the parallel execution of two processes and , where they run independently unless they synchronize via complementary actions on shared channels. This operator is associative and commutative, allowing unrestricted interleaving of actions from and , with the overall behavior emerging from their potential interactions.[46] The pi-calculus, an extension of CCS developed by Milner, Parrow, and Walker, employs the same vertical bar for parallel composition, but with enhanced mobility of channel names to model dynamic communication topologies.[47] In , processes operate concurrently, and synchronization occurs only when an output action in one matches an input in the other along the same channel, facilitating scoped interactions without inherent coupling otherwise. The absence of additional operators with | underscores non-interacting parallelism, where processes evolve autonomously until explicit synchronization is possible.[47] In hardware description languages like Verilog, the vertical bar serves as the bitwise OR operator within concurrent procedural blocks, contributing to parallel signal evaluations. For instance, in an always block such asalways @(posedge clk) a <= b | c;, the assignment computes the OR of inputs and non-blockingly, with the block executing concurrently alongside other always or assign statements to model hardware simultaneity. This usage highlights how logical operations underpin concurrent behavior in digital designs, distinct from sequential control flow.[48]
Array and language-specific uses
In array programming languages like APL and its successor J, the vertical bar denotes the dyadic residue function, which computes the remainder when the right argument is divided by the left argument, effectively implementing a modulo operation with the arguments in reverse order compared to many other languages. For instance, in APL, the expression3 | 10 evaluates to 1, since 10 divided by 3 yields a quotient of 3 and a remainder of 1; this function extends element-wise to arrays, making it efficient for vectorized computations on numerical data.[49] Monadic application of the vertical bar in APL returns the absolute value of its argument, further supporting array manipulations in mathematical contexts.[49]
J, as a modern dialect of APL designed for array processing, retains this usage of the vertical bar for residue, where m | n produces the residue of n modulo m, facilitating concise expressions for tasks like cyclic indexing or hashing in array operations.[50] This operator aligns with J's emphasis on terse, high-performance array computations, often applied to entire matrices without explicit loops.
In functional languages supporting list comprehensions, such as Haskell, the vertical bar separates the output expression and input generators from conditional guards, enabling readable filtering within declarative list constructions. For example, the comprehension [x^2 | x <- [1..10], even x] generates the squares of even numbers from 1 to 10, with the vertical bar delineating the guard even x that restricts the output.[51] This syntax, borrowed from set-builder notation, promotes clarity in defining filtered arrays or lists. Similarly, in function definitions, vertical bars introduce guards for pattern-based dispatching, as in f x | x > 0 = x; | otherwise = -x, allowing conditional logic without nested if-statements.
Python, while supporting list comprehensions for array-like operations, does not utilize the vertical bar in this syntax; guards are instead prefixed with if, as in [x**2 for x in range(1,11) if x % 2 == 0]. Discussions in Python Enhancement Proposals have explored walrus-like assignment operators (e.g., :=) to enhance expressions within comprehensions, but no adoption of the vertical bar for such roles has occurred, avoiding overlap with its bitwise OR usage.[52] In array contexts, the vertical bar can briefly reference string concatenation for joining array elements into delimited strings, though this is handled via methods like join rather than the operator itself.
Markup and formatting
In wiki markup languages, particularly MediaWiki used by projects like Wikimedia, the vertical bar (|) serves as a key delimiter for constructing tables. Tables begin with {| and end with |}, with rows separated by |- and cells defined by single or double pipes: a single | starts a new cell on a fresh line, while || separates multiple cells on the same line. For example, the syntax { | Orange || Apple | } renders as a simple two-column table row. This pipe-based syntax allows embedding complex wiki content within cells and supports attributes like classes (e.g., { | class="wikitable" | cell1 || cell2 | }), enabling styled tabular presentation without HTML tags.[53]
In Markdown, a lightweight markup language popularized for web documentation, certain flavors such as GitHub Flavored Markdown employ the vertical bar (|) to delineate table columns. Tables are formed by separating headers and rows with pipes, with a header row of hyphens (at least three per column) to distinguish it from data rows; pipes at the edges are optional for simplicity. An example is | First Header | Second Header | \n | ------------- | ------------- | \n | Content Cell | Content Cell |, which produces a basic aligned table. Alignment can be adjusted using colons within the hyphen row (e.g., |:---:| for centering), and pipes within cell content must be escaped as \| to avoid misinterpretation. This extension, not part of original Markdown, facilitates readable tabular data in plain text files rendered to HTML.[54]
LaTeX, a typesetting system for technical documents, utilizes the vertical bar (|) in math mode as a basic delimiter for expressions like sets or absolute values, often paired with commands for proper spacing and scaling. The command \vert produces a single vertical bar suitable as an operator or fence, synonymous with the plain | but recommended for mathematical contexts to ensure consistent rendering. For resizable delimiters, \lvert and \rvert from the amsmath package provide left and right variants that auto-scale with \left and \right (e.g., \left\lvert x \right\rvert for matching content height), while manual sizing options like \big| or \Bigl| allow fine control in complex equations. Double bars for norms use \| or \Vert. These features enhance precise mathematical notation in documents.[55]
In HTML and CSS, the vertical bar (|) appears sparingly in markup and styling, primarily within CSS attribute selectors to handle namespaces or hyphen-separated values. For instance, [lang|=en] targets elements with a lang attribute exactly "en" or starting with "en-" (e.g., "en-US"), using the bar as a namespace separator in qualified names like *|E for any namespace's element E. This selector type, defined in CSS specifications, supports targeted styling based on attribute patterns but is less common than basic attribute matching due to its specialized role in internationalized or modular documents.[56]
Linguistics and typography
Phonetic transcription
In the International Phonetic Alphabet (IPA), the vertical bar (|) serves as a suprasegmental symbol to denote a minor (foot) group boundary, marking the separation of smaller prosodic units within an intonation phrase, such as a foot or minor phrase. This usage helps represent the rhythmic and intonational structure of speech, distinguishing it from larger major (intonation) group boundaries marked by double vertical bars (||). For instance, in transcribing English prosody, it can indicate a subtle pause or grouping, as in /ə nɔː| mɑːl/ for "a normal," where the bar highlights the minor phrase break after "nor."[57]Orthographic uses
In Hebrew orthography, the shewa (שְׁוָא) is a diacritical mark represented by two dots arranged vertically beneath a consonant, indicating a reduced or vocalized vowel sound, often an ultra-short -like vowel in the Tiberian tradition of Biblical Hebrew.[58] This mark, which visually resembles a compact vertical bar, distinguishes vocal shewa (with phonetic value) from silent shewa (indicating consonantal quiescence or syllable closure).[59] For instance, in the word שְׁלוֹם (shalom, "peace"), the shewa under the shin signals a vocal onset. Additionally, the paseq (פָּסֵק), a vertical bar (׀), appears in medieval Masoretic manuscripts of the Hebrew Bible to separate words, indicate disjunctive accents, or mark special syntactic divisions, such as preventing sandhi between repeated terms like proper names.[60] This usage underscores its role in clarifying clause boundaries and rhythmic structure in scriptural texts.[61] In certain African writing systems, particularly those of the Khoisan languages spoken in southern Africa, the vertical bar (|) denotes a dental click consonant, a distinctive ingressive sound produced by suction at the teeth. This orthographic convention, rooted in the International Phonetic Alphabet (IPA) and adapted for practical transcription, represents one of five basic click types (alongside alveolar !, lateral ǁ, palatal ǂ, and bilabial ʘ).[62] For example, in the Juǀʼhoan language (formerly known as !Kung), the word |xòã refers to "eland," where the initial | indicates the dental click followed by a velar fricative and nasal vowel. Such usage integrates the vertical bar into the core phonemic inventory, essential for distinguishing lexical items in these non-Bantu tonal languages.[63] This practice parallels the capitulum, a stylized "C" intersected by a vertical bar, used for paragraph or sentence separation from the 11th century onward.[64] In contemporary typography, the vertical bar occasionally serves as a substitute for the em dash (—) in plain-text environments or specific typesetting systems to denote abrupt breaks, interruptions, or parenthetical insertions, especially where full typographic control is limited. This adaptation highlights the bar's versatility in maintaining readability across media, though style guides like The Chicago Manual of Style recommend the true em dash for formal print.Literary and artistic applications
In poetry and verse analysis, the vertical bar serves as a notation tool in scansion to delineate metrical feet within a line. The Text Encoding Initiative (TEI) standards specify its use for marking foot divisions, with line breaks indicated separately by a solidus (/), enabling precise encoding of poetic structure in digital literary editions.[65] This application highlights the bar's role in facilitating rhythmic and structural breakdown for scholars and performers. In music scoring, the single vertical bar functions as a bar line to separate measures, particularly in tablature systems like guitar tabs, where it divides the notation into rhythmic segments for instrumentalists.[66] The double vertical bar (||), consisting of two closely spaced lines, denotes the end of a major section, a key change, or the conclusion of a composition, providing clear structural boundaries in scores.[67] Artistic applications extend to experimental notation, as seen in John Cage's 4'33" (1952/1953), where vertical lines proportionally represent temporal divisions of silence across the piece's three movements, transforming absence into a measurable compositional element. This innovative use equates space to time, emphasizing ambient sounds as music.[68]Variants and encoding
Broken bar
The broken bar (¦) is a typographic variant of the vertical bar featuring a visible gap in its middle, designed to provide visual distinction from the solid vertical bar (|). This symbol emerged as a deliberate choice in early computing standards to differentiate it from similar glyphs, such as the exclamation mark when stylized vertically or other separators in programming languages like PL/I.[69] The solid vertical bar (|) was included in the original ASA X3.4-1963 ASCII standard at code point 7Ch (decimal 124). The 1967 revision (X3.4-1967) changed it to the broken bar to resolve ambiguities in international character sets and support specific needs in programming and data transmission, particularly to distinguish from the solid bar in EBCDIC.[70] By the 1977 revision of ANSI X3.4, the standard reverted to the solid vertical bar at 7Ch, reflecting a preference for the unbroken form in evolving computing practices. Early typewriters and computer keyboards often rendered this code point as broken to align with the 1967-1968 standards, influencing fonts in systems like IBM PCs.[71] In modern contexts, the broken bar appears primarily in legacy systems or specific keyboard layouts, such as the UK variant where it serves as an alternative to the pipe symbol via AltGr key combinations. It is rarely used in mathematics, where the solid vertical bar or double bar (||) is the standard for notations like absolute value or norms. Unicode encodes the broken bar separately at U+00A6 while designating U+007C for the vertical bar in general applications, effectively discouraging the broken form for new typographic or programming uses in favor of the solid variant.[72]Unicode representation
The vertical bar is encoded in Unicode as U+007C VERTICAL LINE, classified under the Symbol, Math (Sm) category within the Basic Latin block.[73][74] This code point represents a solid vertical line used across various scripts and contexts, with a bidirectional class of Other Neutral (ON) and no mirroring property.[75] The character is not decomposable and has no canonical or compatibility decompositions, ensuring its atomic representation in normalized Unicode text.[75] A fullwidth variant exists at U+FF5C FULLWIDTH VERTICAL LINE (|), part of the Halfwidth and Fullwidth Forms block, designed for East Asian typography where it occupies a full character width equivalent to ideographs.[76][77] Rendering of U+007C can vary across fonts; for instance, some monospace fonts display it as a thin, unbroken line, while proportional fonts may adjust its thickness for aesthetic balance, occasionally leading to visual confusion with similar symbols like the broken bar (U+00A6).[2] No dedicated zero-width variant exists for the vertical bar in Unicode, though in specialized contexts such as text segmentation or invisible markup, alternatives like the zero-width space (U+200B) may be used adjacently to control layout without visible interruption.[78] As of Unicode 17.0 released in September 2025, no major changes have been made to U+007C itself.[79]Legacy encodings
The vertical bar character (|) was standardized in the American Standard Code for Information Interchange (ASCII) at position 124 decimal (7C hexadecimal) upon its initial publication as ASA X3.4-1963. This encoding allowed the vertical bar to be represented consistently in early digital communications and computing systems supporting seven-bit teleprinter codes.[80] In contrast, IBM's Extended Binary Coded Decimal Interchange Code (EBCDIC), developed in the late 1950s and widely used in mainframe systems, assigned the vertical bar to varying positions across code pages, such as 0x6F hexadecimal in code page 037. These discrepancies, including mappings where the vertical bar code point in one EBCDIC code page corresponded to other symbols like the exclamation mark in another EBCDIC code page, led to significant portability challenges when exchanging data between EBCDIC-based IBM environments and ASCII systems.[81] The International Organization for Standardization's ISO 8859-1 (Latin-1), published in 1987 for Western European languages, retained the ASCII-compatible encoding for the vertical bar at 0x7C, ensuring backward compatibility with seven-bit ASCII in the lower 128 code points.[82] Early hardware implementations, such as the Teletype Model 33 introduced in 1963, utilized the vertical bar within ASCII shift states for character selection and printing on electromechanical teleprinters during the 1960s.[83] These legacy encodings laid the groundwork for later standards like Unicode, which superseded them by unifying character representations across diverse systems.References
- https://www.mediawiki.org/wiki/Help:Tables
